Submission #1832085
Source Code Expand
#include <cstdio> #include <cstdlib> #include <cstring> #include <cctype> #include <cmath> #include <algorithm> #define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i) #define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i) #define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i) #define ri rd<int> #define rl rd<LL> typedef long long LL; using namespace std; const int maxN = 1e5 + 7; template<class T> inline T rd() { bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0; T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x; } LL q[maxN]; int m, Top, V; LL a[maxN], f[maxN]; int find(int l, int r, LL d) { int mid; while (l < r) { mid = (l + r) / 2 + 1; if (q[mid] <= d) l = mid; else r = mid - 1; } return l; } void F(int n, LL d, LL t) { if (d == 0 || t == 0) return; if (n == 1) {a[d] += t; return;} int p = find(1, n-1, d); f[p] += t * (d / q[p]); F(p, d % q[p], t); } int main() { V = q[Top = 1] = rl(); m = ri(); while (m --) { LL x = rl(); while (Top && q[Top] >= x) -- Top; q[++Top] = x; } m = Top; f[m] = 1; per (i, m, 1) F(i, q[i], f[i]); per (i, V, 1) a[i] += a[i+1]; rep (i, 1, V) printf("%lld\n", a[i]); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Sequential operations on Sequence |
User | acha |
Language | C++14 (GCC 5.4.1) |
Score | 1400 |
Code Size | 1308 Byte |
Status | AC |
Exec Time | 52 ms |
Memory | 3968 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 | 2176 KB |
02.txt | AC | 28 ms | 2304 KB |
03.txt | AC | 27 ms | 2304 KB |
04.txt | AC | 27 ms | 2432 KB |
05.txt | AC | 27 ms | 2304 KB |
06.txt | AC | 37 ms | 3840 KB |
07.txt | AC | 38 ms | 3968 KB |
08.txt | AC | 38 ms | 3968 KB |
09.txt | AC | 41 ms | 3840 KB |
10.txt | AC | 38 ms | 3840 KB |
11.txt | AC | 37 ms | 3968 KB |
12.txt | AC | 39 ms | 3840 KB |
13.txt | AC | 40 ms | 3968 KB |
14.txt | AC | 37 ms | 3840 KB |
15.txt | AC | 37 ms | 3840 KB |
16.txt | AC | 38 ms | 3840 KB |
17.txt | AC | 38 ms | 3968 KB |
18.txt | AC | 37 ms | 3840 KB |
19.txt | AC | 36 ms | 3840 KB |
20.txt | AC | 39 ms | 3968 KB |
21.txt | AC | 52 ms | 2688 KB |
22.txt | AC | 34 ms | 3584 KB |
23.txt | AC | 43 ms | 3840 KB |
24.txt | AC | 30 ms | 3840 KB |
25.txt | AC | 29 ms | 3712 KB |
26.txt | AC | 25 ms | 2688 KB |
27.txt | AC | 13 ms | 1152 KB |
28.txt | AC | 13 ms | 1152 KB |
29.txt | AC | 13 ms | 1152 KB |
30.txt | AC | 14 ms | 1152 KB |
31.txt | AC | 1 ms | 128 KB |
32.txt | AC | 9 ms | 1152 KB |
33.txt | AC | 1 ms | 128 KB |
34.txt | AC | 12 ms | 2432 KB |
35.txt | AC | 1 ms | 128 KB |
36.txt | AC | 1 ms | 128 KB |
s1.txt | AC | 1 ms | 128 KB |
s2.txt | AC | 1 ms | 128 KB |