Submission #1366888
Source Code Expand
#include <cstdio> #include <set> #define fin stdin #define fout stdout #define ll long long #define mult std::set <myc> #define MAXN 100000 struct myc{ ll x, y; myc(ll _x, ll _y){ x = _x; y = _y; } inline bool operator < (const myc &u) const { return x > u.x; } }; mult s; ll st[MAXN + 2]; ll ans[MAXN + 1]; inline void baga(myc a){ mult::iterator it = s.lower_bound(a); if (it != s.end() && it -> x == a.x) { a.y += it -> y; s.erase(it); } s.insert(a); } int main(){ int n, q; fscanf(fin, "%d%d", &n, &q); int vf = 1; st[1] = n; for (int i = 0; i < q; i++) { ll x; fscanf(fin, "%lld", &x); while (vf > 0 && st[vf] >= x) vf--; st[++vf] = x; } for (int i = 1; i <= vf; i++) s.insert(myc(st[i], bool (i == vf))); while ((*(s.begin())).x > st[1]) { myc a = *(s.begin()); s.erase(s.begin()); myc b = *(s.begin()); s.erase(s.begin()); b.y += a.y * (a.x / b.x); baga(b); if (a.x % b.x) baga(myc(a.x % b.x, a.y)); } for (auto &u : s) ans[u.x] += u.y; for (int i = n - 1; i > 0; i--) ans[i] += ans[i + 1]; for(int i = 1; i <= n; i++) fprintf(fout, "%lld\n", ans[i]); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Sequential operations on Sequence |
User | alexpetrescu |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1445 Byte |
Status | WA |
Exec Time | 164 ms |
Memory | 9472 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:40:32: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] fscanf(fin, "%d%d", &n, &q); ^ ./Main.cpp:46:32: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] fscanf(fin, "%lld", &x); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | WA | 29 ms | 2304 KB |
02.txt | WA | 29 ms | 2432 KB |
03.txt | WA | 29 ms | 2432 KB |
04.txt | WA | 29 ms | 2432 KB |
05.txt | WA | 29 ms | 2432 KB |
06.txt | WA | 164 ms | 9472 KB |
07.txt | WA | 163 ms | 9472 KB |
08.txt | WA | 164 ms | 9472 KB |
09.txt | WA | 157 ms | 9472 KB |
10.txt | WA | 160 ms | 9472 KB |
11.txt | WA | 159 ms | 9472 KB |
12.txt | WA | 160 ms | 9472 KB |
13.txt | WA | 158 ms | 9472 KB |
14.txt | WA | 153 ms | 9472 KB |
15.txt | WA | 161 ms | 9472 KB |
16.txt | WA | 159 ms | 9472 KB |
17.txt | WA | 158 ms | 9472 KB |
18.txt | WA | 155 ms | 9472 KB |
19.txt | WA | 160 ms | 9472 KB |
20.txt | WA | 158 ms | 9472 KB |
21.txt | AC | 150 ms | 8192 KB |
22.txt | WA | 155 ms | 9088 KB |
23.txt | AC | 134 ms | 9472 KB |
24.txt | WA | 97 ms | 9344 KB |
25.txt | WA | 98 ms | 9216 KB |
26.txt | WA | 88 ms | 8064 KB |
27.txt | AC | 18 ms | 1152 KB |
28.txt | AC | 18 ms | 1152 KB |
29.txt | AC | 18 ms | 1152 KB |
30.txt | AC | 19 ms | 1152 KB |
31.txt | AC | 1 ms | 256 KB |
32.txt | AC | 9 ms | 1152 KB |
33.txt | AC | 1 ms | 256 KB |
34.txt | AC | 12 ms | 2432 KB |
35.txt | AC | 1 ms | 256 KB |
36.txt | WA | 1 ms | 256 KB |
s1.txt | AC | 1 ms | 256 KB |
s2.txt | AC | 1 ms | 256 KB |