Submission #848319
Source Code Expand
Copy
#include<bits/stdc++.h> using namespace std; #define MAX 100002 int n; int q; vector<long long int> v; map<long long int, long long int> mp; map<long long int, long long int> nex; long long int im[MAX]; int main(){ cin >> n; cin >> q; v.push_back(n); for (int i = 0; i < q; i++){ long long int a; scanf("%lld", &a); v.push_back(a); } long long int cur_len = v.back(); mp[-cur_len] = 1; for (int i = v.size() - 1; i > 0; i--){ nex.clear(); long long int pr = v[i - 1]; vector<long long int> del; for (auto it = mp.begin(); it != mp.end(); it++){ long long int val = -(*it).first; if (val <= pr){ break; } long long int se = (*it).second; long long int sa = val / pr; nex[pr] += sa*se; sa = val%pr; if (sa){ nex[sa] += se; } del.push_back((*it).first); } for (int j = 0; j < del.size(); j++){ mp.erase(del[j]); } for (auto it = nex.begin(); it != nex.end(); it++){ mp[-(*it).first] += (*it).second; } } for (auto it = mp.begin(); it != mp.end(); it++){ im[-(*it).first] += (*it).second; } for (int i = n-1; i >= 1; i--){ im[i] += im[i + 1]; } for (int i = 1; i <= n; i++){ printf("%lld\n", im[i]); } return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Sequential operations on Sequence |
User | Kmcode |
Language | C++14 (GCC 5.4.1) |
Score | 1400 |
Code Size | 1268 Byte |
Status | AC |
Exec Time | 397 ms |
Memory | 12888 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:23:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld", &a); ^
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 | 61 ms | 3188 KB |
02.txt | AC | 62 ms | 3316 KB |
03.txt | AC | 62 ms | 3316 KB |
04.txt | AC | 62 ms | 3316 KB |
05.txt | AC | 62 ms | 3316 KB |
06.txt | AC | 273 ms | 11492 KB |
07.txt | AC | 325 ms | 12888 KB |
08.txt | AC | 298 ms | 12360 KB |
09.txt | AC | 311 ms | 10188 KB |
10.txt | AC | 273 ms | 10788 KB |
11.txt | AC | 250 ms | 11672 KB |
12.txt | AC | 308 ms | 11512 KB |
13.txt | AC | 324 ms | 10808 KB |
14.txt | AC | 262 ms | 11556 KB |
15.txt | AC | 249 ms | 11428 KB |
16.txt | AC | 289 ms | 11192 KB |
17.txt | AC | 290 ms | 11472 KB |
18.txt | AC | 272 ms | 11548 KB |
19.txt | AC | 231 ms | 11412 KB |
20.txt | AC | 286 ms | 11360 KB |
21.txt | AC | 397 ms | 8180 KB |
22.txt | AC | 349 ms | 12160 KB |
23.txt | AC | 267 ms | 9460 KB |
24.txt | AC | 94 ms | 3188 KB |
25.txt | AC | 95 ms | 3060 KB |
26.txt | AC | 84 ms | 2164 KB |
27.txt | AC | 40 ms | 2164 KB |
28.txt | AC | 40 ms | 2164 KB |
29.txt | AC | 40 ms | 2164 KB |
30.txt | AC | 40 ms | 2164 KB |
31.txt | AC | 4 ms | 256 KB |
32.txt | AC | 19 ms | 1152 KB |
33.txt | AC | 4 ms | 256 KB |
34.txt | AC | 28 ms | 2432 KB |
35.txt | AC | 4 ms | 256 KB |
36.txt | AC | 4 ms | 256 KB |
s1.txt | AC | 4 ms | 256 KB |
s2.txt | AC | 4 ms | 256 KB |