Submission #1776345
Source Code Expand
#include <cstdio> #include <cstring> #include <string> #include <cmath> #include <iostream> #include <algorithm> #include <map> #include <set> #include <queue> #include <vector> using namespace std; typedef long long ll; typedef unsigned int uint; typedef unsigned long long ull; typedef pair<int, int> PII; typedef vector<int> VI; #define fi first #define se second #define MP make_pair ll read() { ll v = 0, f = 1; char c = getchar(); while (c < 48 || 57 < c) {if (c == '-') f = -1; c = getchar();} while (48 <= c && c <= 57) v = (v << 3) + v + v + c - 48, c = getchar(); return v * f; } const ll INF = 2e18; const ll N = 1e5 + 10; ll _n, n, m, a[N], b[N], ans[N]; int main() { _n = a[0] = read(); n = read(); for (int i = 1; i <= n; i++) a[i] = read(); m = -1; for (int i = n; i >= 0; ) { int j; for (j = i; j >= 0; j--) if (a[j] < a[i]) break; b[++m] = a[i]; i = j; } reverse(b, b + m + 1); for (int i = 0; i <= m; i++) a[i] = b[i]; n = m; for (int i = 0; i <= n; i++) b[i] = 0; b[n] = 1; for (int i = n; i >= 1; i--) while (1) { int t = upper_bound(a, a + i, a[i]) - a - 1; if (t == -1) { ans[a[i]] += b[i]; break; } else { b[t] += (a[i] / a[t]) * b[i]; a[i] %= a[t]; } } for (int i = a[0] - 1; i >= 1; i--) ans[i] += ans[i + 1]; for (int i = 1; i <= a[0]; i++) printf("%lld ", ans[i] + b[0]); for (int i = a[0] + 1; i <= _n; i++) printf("0 "); puts(""); }
Submission Info
Submission Time | |
---|---|
Task | E - Sequential operations on Sequence |
User | Misaka10032 |
Language | C++14 (GCC 5.4.1) |
Score | 1400 |
Code Size | 1757 Byte |
Status | AC |
Exec Time | 49 ms |
Memory | 4096 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 1400 / 1400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, s1.txt, s2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | AC | 27 ms | 3072 KB |
02.txt | AC | 28 ms | 3200 KB |
03.txt | AC | 27 ms | 3200 KB |
04.txt | AC | 28 ms | 3200 KB |
05.txt | AC | 27 ms | 3200 KB |
06.txt | AC | 38 ms | 3968 KB |
07.txt | AC | 40 ms | 4096 KB |
08.txt | AC | 40 ms | 4096 KB |
09.txt | AC | 42 ms | 3968 KB |
10.txt | AC | 38 ms | 3968 KB |
11.txt | AC | 37 ms | 4096 KB |
12.txt | AC | 41 ms | 3968 KB |
13.txt | AC | 42 ms | 4096 KB |
14.txt | AC | 38 ms | 3968 KB |
15.txt | AC | 37 ms | 3968 KB |
16.txt | AC | 39 ms | 3968 KB |
17.txt | AC | 40 ms | 4096 KB |
18.txt | AC | 38 ms | 3968 KB |
19.txt | AC | 36 ms | 3968 KB |
20.txt | AC | 40 ms | 4096 KB |
21.txt | AC | 49 ms | 2048 KB |
22.txt | AC | 35 ms | 3712 KB |
23.txt | AC | 45 ms | 3968 KB |
24.txt | AC | 28 ms | 3840 KB |
25.txt | AC | 27 ms | 3712 KB |
26.txt | AC | 18 ms | 2048 KB |
27.txt | AC | 9 ms | 1280 KB |
28.txt | AC | 15 ms | 2048 KB |
29.txt | AC | 15 ms | 2048 KB |
30.txt | AC | 15 ms | 2048 KB |
31.txt | AC | 1 ms | 256 KB |
32.txt | AC | 10 ms | 1280 KB |
33.txt | AC | 1 ms | 256 KB |
34.txt | AC | 13 ms | 2560 KB |
35.txt | AC | 1 ms | 256 KB |
36.txt | AC | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |