Submission #1386740
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxx = 1e5 + 20; ll sz, qu[maxx], n, q, t[maxx], ps[maxx], b[maxx]; stack<int> stk; vector<int> v; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> q; stk.push(n); for(int 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(int i = 0; i < v.size(); i++) b[i] = -v[i]; reverse(v.begin(), v.end()); sz = v.size(); t[sz-1] = 1; for(int i = sz - 1; i >= 0; i--) { int k = v[i]; while (i && k >= v[0]) { int 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(int i = n - 1; i >= 0; i--) ps[i] = (ps[i+1] + ps[i]); for(int 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 | 0 |
Code Size | 1089 Byte |
Status | RE |
Exec Time | 2103 ms |
Memory | 2740 KB |
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 | RE | 112 ms | 2612 KB |
02.txt | RE | 112 ms | 2612 KB |
03.txt | RE | 112 ms | 2612 KB |
04.txt | TLE | 2103 ms | 2612 KB |
05.txt | RE | 111 ms | 2612 KB |
06.txt | TLE | 2103 ms | 2612 KB |
07.txt | TLE | 2103 ms | 2612 KB |
08.txt | TLE | 2103 ms | 2612 KB |
09.txt | RE | 111 ms | 2612 KB |
10.txt | TLE | 2103 ms | 2612 KB |
11.txt | RE | 111 ms | 2612 KB |
12.txt | RE | 111 ms | 2612 KB |
13.txt | RE | 111 ms | 2612 KB |
14.txt | RE | 112 ms | 2612 KB |
15.txt | TLE | 2103 ms | 2612 KB |
16.txt | TLE | 2103 ms | 2612 KB |
17.txt | RE | 111 ms | 2612 KB |
18.txt | RE | 111 ms | 2612 KB |
19.txt | TLE | 2103 ms | 2612 KB |
20.txt | TLE | 2103 ms | 2612 KB |
21.txt | RE | 109 ms | 2612 KB |
22.txt | RE | 110 ms | 2612 KB |
23.txt | TLE | 2103 ms | 2612 KB |
24.txt | RE | 109 ms | 2612 KB |
25.txt | RE | 109 ms | 2740 KB |
26.txt | RE | 109 ms | 2612 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 | 16 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 | RE | 96 ms | 256 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 |