Submission #1386743
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; const ll maxx = 1e5 + 20; ll sz, qu[maxx], n, q, t[maxx], ps[maxx], b[maxx]; stack<ll> stk; vector<ll> v; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> q; stk.push(n); for(ll i = 0; i < q; i++) { cin >> qu[i]; while (stk.size() && stk.top() >= qu[i]) stk.pop(); stk.push(qu[i]); } while (stk.size()) v.push_back(stk.top()), stk.pop(); for(ll i = 0; i < v.size(); i++) b[i] = -v[i]; reverse(v.begin(), v.end()); sz = v.size(); t[sz-1] = 1; for(ll i = sz - 1; i >= 0; i--) { ll k = v[i]; while (i && k >= v[0]) { ll r = lower_bound(b + sz - i, b + sz, -k) - b; // cout << i << " " << r << " " << b[r] << " " << k << endl; t[sz - r - 1] += (t[i] * (k / (-b[r]))); k = (k % (-b[r])); // return 0; } ps[k] += t[i]; // if (i == 0) break; } // ps[n] = t[n]; for(ll i = n - 1; i >= 0; i--) ps[i] = (ps[i+1] + ps[i]); for(ll i = 1; i <= n; i++) cout << ps[i] << '\n'; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Sequential operations on Sequence |
User | Behnood |
Language | C++14 (GCC 5.4.1) |
Score | 1400 |
Code Size | 1079 Byte |
Status | AC |
Exec Time | 66 ms |
Memory | 6448 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 | 27 ms | 3200 KB |
03.txt | AC | 27 ms | 3200 KB |
04.txt | AC | 27 ms | 3200 KB |
05.txt | AC | 27 ms | 3200 KB |
06.txt | AC | 40 ms | 6320 KB |
07.txt | AC | 44 ms | 6448 KB |
08.txt | AC | 43 ms | 6432 KB |
09.txt | AC | 45 ms | 6304 KB |
10.txt | AC | 40 ms | 6320 KB |
11.txt | AC | 38 ms | 6448 KB |
12.txt | AC | 44 ms | 6304 KB |
13.txt | AC | 45 ms | 6432 KB |
14.txt | AC | 39 ms | 6320 KB |
15.txt | AC | 38 ms | 6320 KB |
16.txt | AC | 42 ms | 6304 KB |
17.txt | AC | 42 ms | 6432 KB |
18.txt | AC | 40 ms | 6320 KB |
19.txt | AC | 37 ms | 6320 KB |
20.txt | AC | 42 ms | 6432 KB |
21.txt | AC | 66 ms | 5168 KB |
22.txt | AC | 38 ms | 6064 KB |
23.txt | AC | 50 ms | 6320 KB |
24.txt | AC | 28 ms | 6304 KB |
25.txt | AC | 28 ms | 6176 KB |
26.txt | AC | 24 ms | 5168 KB |
27.txt | AC | 16 ms | 2048 KB |
28.txt | AC | 16 ms | 2048 KB |
29.txt | AC | 16 ms | 2048 KB |
30.txt | AC | 17 ms | 2048 KB |
31.txt | AC | 1 ms | 256 KB |
32.txt | AC | 8 ms | 1280 KB |
33.txt | AC | 1 ms | 256 KB |
34.txt | AC | 11 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 |