Submission #1842250
Source Code Expand
#include <iostream> #include <cstdio> #include <cstring> using namespace std; typedef long long ll; const int MAXN = 1e5 + 10; ll v[MAXN] , ans[MAXN] , has[MAXN]; int sum = 1 , q , n; int main(){ cin >> n >> q; v[1] = n; for(int i = 1 ; i <= q ; ++ i){ ll x; cin >> x; while(sum && x < v[sum]) sum --; v[++ sum] = x; } has[sum] = 1; for(int i = sum ; i >= 1 ; -- i){ if(has[i] == 0) continue; ll now = v[i]; int last = i; while(true){ int ll = 0 , rr = last - 1; while(ll < rr){ int mid = (ll + rr + 1) >> 1; if(now >= v[mid]) ll = mid; else rr = mid - 1; } if(ll == 0){ ans[now] += has[i]; break; } else{ has[ll] += now / v[ll] * has[i]; now %= v[ll]; last = ll; } } } for(int i = n ; i >= 1 ; -- i) ans[i - 1] += ans[i]; for(int i = 1 ; i <= n ; ++ i) cout << ans[i] << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Sequential operations on Sequence |
User | Rchen |
Language | C++14 (GCC 5.4.1) |
Score | 1400 |
Code Size | 1020 Byte |
Status | AC |
Exec Time | 241 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 | 223 ms | 2304 KB |
02.txt | AC | 225 ms | 2432 KB |
03.txt | AC | 228 ms | 2432 KB |
04.txt | AC | 226 ms | 2432 KB |
05.txt | AC | 224 ms | 2432 KB |
06.txt | AC | 231 ms | 3968 KB |
07.txt | AC | 237 ms | 4096 KB |
08.txt | AC | 234 ms | 4096 KB |
09.txt | AC | 238 ms | 3968 KB |
10.txt | AC | 231 ms | 3968 KB |
11.txt | AC | 232 ms | 4096 KB |
12.txt | AC | 238 ms | 3968 KB |
13.txt | AC | 232 ms | 4096 KB |
14.txt | AC | 232 ms | 3968 KB |
15.txt | AC | 235 ms | 3968 KB |
16.txt | AC | 234 ms | 3968 KB |
17.txt | AC | 241 ms | 4096 KB |
18.txt | AC | 234 ms | 3968 KB |
19.txt | AC | 238 ms | 3968 KB |
20.txt | AC | 234 ms | 4096 KB |
21.txt | AC | 237 ms | 2816 KB |
22.txt | AC | 223 ms | 3712 KB |
23.txt | AC | 239 ms | 3968 KB |
24.txt | AC | 219 ms | 3840 KB |
25.txt | AC | 216 ms | 3712 KB |
26.txt | AC | 202 ms | 2816 KB |
27.txt | AC | 180 ms | 1280 KB |
28.txt | AC | 188 ms | 2816 KB |
29.txt | AC | 190 ms | 2816 KB |
30.txt | AC | 193 ms | 2816 KB |
31.txt | AC | 1 ms | 256 KB |
32.txt | AC | 154 ms | 1280 KB |
33.txt | AC | 1 ms | 256 KB |
34.txt | AC | 162 ms | 2432 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 |