Submission #848381


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;
		del.clear();
		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;
		}
		nex.clear();
	}
	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 1300 Byte
Status AC
Exec Time 414 ms
Memory 12160 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
AC × 2
AC × 38
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 63 ms 3188 KB
02.txt AC 64 ms 3316 KB
03.txt AC 64 ms 3316 KB
04.txt AC 64 ms 3316 KB
05.txt AC 63 ms 3316 KB
06.txt AC 300 ms 11472 KB
07.txt AC 378 ms 10908 KB
08.txt AC 326 ms 10944 KB
09.txt AC 345 ms 8124 KB
10.txt AC 313 ms 10844 KB
11.txt AC 264 ms 11672 KB
12.txt AC 356 ms 10560 KB
13.txt AC 414 ms 10712 KB
14.txt AC 309 ms 11560 KB
15.txt AC 283 ms 11428 KB
16.txt AC 314 ms 10944 KB
17.txt AC 348 ms 11524 KB
18.txt AC 304 ms 11576 KB
19.txt AC 243 ms 11412 KB
20.txt AC 304 ms 10932 KB
21.txt AC 392 ms 8180 KB
22.txt AC 352 ms 12160 KB
23.txt AC 246 ms 9460 KB
24.txt AC 96 ms 3188 KB
25.txt AC 95 ms 3060 KB
26.txt AC 85 ms 2164 KB
27.txt AC 49 ms 2164 KB
28.txt AC 42 ms 2164 KB
29.txt AC 43 ms 2164 KB
30.txt AC 43 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