Submission #847933
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long LL; int main(){ int n; int q; cin >> n >> q; vector<LL > c; for(int i = 0; i < q; i++){ LL a; cin >> a; c.push_back(a); } LL m = 2e18; vector<LL> b; for(int i = q-1; i >= 0; i--){ if(c[i] < m){ b.push_back(c[i]); m = c[i]; } } if(n < m){ b.push_back(n); m = n; } map<LL,LL> freq; freq[b[0]] = 1; cout << b[0] << endl; for(int i = 1; i < b.size(); i++){ /*for(map<LL,LL>::iterator it = freq.begin(); it != freq.end(); it++){ cout << it->first << " " << it->second << endl; }*/ while(freq.rbegin()->first > b[i]){ LL d = freq.rbegin()->first; cout << b[i] << " " << d << endl; LL a = freq.rbegin()->second; cout << d << " " << a << " " << endl; freq[b[i]] += (d/b[i])*a; freq[d%b[i]] += a; freq[d] = 0; freq.erase(d); } } LL diff[n+5]; for(int i = 0; i <= n+3; i++){ diff[i] = 0; } /*for(map<LL,LL>::iterator it = freq.begin(); it != freq.end(); it++){ cout << it->first << " " << it->second << endl; }*/ while(!freq.empty() && freq.rbegin()->first > 0){ LL d = freq.rbegin()->first; LL a = freq.rbegin()->second; diff[d] += a; freq[d] = 0; freq.erase(d); } for(int i = m; i >= 1; i--){ diff[i] = diff[i] + diff[i+1]; } for(int i = 1; i <= n; i++){ cout << diff[i] << endl; } }
Submission Info
Submission Time | |
---|---|
Task | E - Sequential operations on Sequence |
User | ksun48 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1407 Byte |
Status | WA |
Exec Time | 2102 ms |
Memory | 15732 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 | 695 ms | 3188 KB |
02.txt | WA | 701 ms | 3316 KB |
03.txt | WA | 708 ms | 3316 KB |
04.txt | WA | 732 ms | 3316 KB |
05.txt | WA | 721 ms | 3316 KB |
06.txt | TLE | 2102 ms | 14324 KB |
07.txt | TLE | 2102 ms | 14324 KB |
08.txt | TLE | 2102 ms | 14452 KB |
09.txt | TLE | 2102 ms | 14580 KB |
10.txt | TLE | 2102 ms | 14452 KB |
11.txt | TLE | 2102 ms | 14324 KB |
12.txt | TLE | 2102 ms | 14452 KB |
13.txt | TLE | 2102 ms | 14452 KB |
14.txt | TLE | 2102 ms | 14452 KB |
15.txt | TLE | 2102 ms | 14324 KB |
16.txt | TLE | 2102 ms | 14452 KB |
17.txt | TLE | 2102 ms | 14452 KB |
18.txt | TLE | 2102 ms | 14452 KB |
19.txt | TLE | 2102 ms | 14196 KB |
20.txt | TLE | 2102 ms | 14452 KB |
21.txt | TLE | 2102 ms | 14196 KB |
22.txt | TLE | 2102 ms | 14324 KB |
23.txt | TLE | 2102 ms | 15732 KB |
24.txt | WA | 1931 ms | 8436 KB |
25.txt | WA | 1993 ms | 8308 KB |
26.txt | WA | 1933 ms | 6644 KB |
27.txt | WA | 627 ms | 2164 KB |
28.txt | WA | 630 ms | 2164 KB |
29.txt | WA | 634 ms | 2164 KB |
30.txt | WA | 629 ms | 2164 KB |
31.txt | WA | 4 ms | 256 KB |
32.txt | WA | 572 ms | 1152 KB |
33.txt | WA | 4 ms | 256 KB |
34.txt | WA | 579 ms | 2432 KB |
35.txt | WA | 4 ms | 256 KB |
36.txt | WA | 4 ms | 256 KB |
s1.txt | WA | 4 ms | 256 KB |
s2.txt | WA | 4 ms | 256 KB |