Submission #847949
Source Code Expand
Copy
#include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL,LL> PII; int main() { LL N,Q; cin >> N >> Q; vector<LL> pos; pos.push_back(0); pos.push_back(N); for(int i=0; i<Q; i++) { LL q; cin >> q; while(q <= pos.back()) pos.pop_back(); pos.push_back(q); } // vector<LL> nums; priority_queue<PII> num; LL mult = 1; // num.push(ma); for(int i=pos.size()-2; i>=1; i--) { assert(pos[i+1] > pos[i]); num.push(PII(pos[i+1] % pos[i], mult)); mult = mult * (pos[i+1] / pos[i]); while(true) { if(num.empty()) break; if(num.top().first < pos[i]) break; PII cur = num.top(); num.pop(); mult += cur.first / pos[i]; num.push(PII(cur.first % pos[i], cur.second)); } } vector<LL> imos(N+1, 0); while(!num.empty()) { PII cur = num.top(); num.pop(); if(cur.first>0) imos[cur.first-1] += cur.second; } for(int i=N-1; i>=0; i--) { imos[i] += imos[i+1]; } for(int i=0; i<pos[1]; i++) imos[i] += mult; for(int i=0; i<N; i++) { cout << imos[i] << endl; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Sequential operations on Sequence |
User | tokoharu |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1110 Byte |
Status | WA |
Exec Time | 952 ms |
Memory | 4720 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 | WA | 712 ms | 2176 KB |
02.txt | WA | 709 ms | 2432 KB |
03.txt | WA | 742 ms | 2304 KB |
04.txt | WA | 716 ms | 2304 KB |
05.txt | WA | 708 ms | 2304 KB |
06.txt | WA | 793 ms | 4720 KB |
07.txt | WA | 820 ms | 4720 KB |
08.txt | WA | 943 ms | 4720 KB |
09.txt | WA | 836 ms | 4720 KB |
10.txt | WA | 791 ms | 4720 KB |
11.txt | WA | 775 ms | 4720 KB |
12.txt | WA | 952 ms | 4720 KB |
13.txt | WA | 807 ms | 4720 KB |
14.txt | WA | 929 ms | 4720 KB |
15.txt | WA | 919 ms | 4720 KB |
16.txt | WA | 874 ms | 4720 KB |
17.txt | WA | 799 ms | 4720 KB |
18.txt | WA | 788 ms | 4720 KB |
19.txt | WA | 771 ms | 4720 KB |
20.txt | WA | 795 ms | 4720 KB |
21.txt | WA | 907 ms | 3568 KB |
22.txt | WA | 769 ms | 4336 KB |
23.txt | WA | 834 ms | 4464 KB |
24.txt | WA | 707 ms | 3824 KB |
25.txt | WA | 786 ms | 3952 KB |
26.txt | WA | 795 ms | 3568 KB |
27.txt | AC | 623 ms | 1152 KB |
28.txt | AC | 687 ms | 1152 KB |
29.txt | AC | 621 ms | 1152 KB |
30.txt | AC | 624 ms | 1280 KB |
31.txt | AC | 4 ms | 256 KB |
32.txt | AC | 580 ms | 1280 KB |
33.txt | AC | 4 ms | 256 KB |
34.txt | AC | 622 ms | 2432 KB |
35.txt | AC | 4 ms | 256 KB |
36.txt | WA | 4 ms | 256 KB |
s1.txt | AC | 4 ms | 256 KB |
s2.txt | AC | 4 ms | 256 KB |