Submission #847488


Source Code Expand

Copy
#include<bits/stdc++.h>
#define N 100100
using namespace std;
map<long long,long long,greater<long long> > num; 
long long a[N];
long long ans[N];
int main(){
	int n,q;
	long long mn;
	scanf("%d%d",&n,&q);
	a[0]=n;
	for(int i=1;i<=q;i++){
		scanf("%lld",&a[i]);
	}
	mn=a[q];
	num[a[q]]=1;
	for(int i=q-1;i>=0;i--){
		if(a[i]<mn){
			mn=a[i];
			for(auto it=num.begin();it!=num.end()&&it->first>a[i];it=num.erase(it)){
				num[a[i]]+=it->first/a[i]*it->second;
				if(it->first%a[i]) num[it->first%a[i]]+=it->second;
			}
		}
	}
	for(int i=n;i>=1;i--){
		ans[i]=ans[i+1]+num[i];
	}
	for(int i=1;i<=n;i++) printf("%lld\n",ans[i]);
	return 0;
}

Submission Info

Submission Time
Task E - Sequential operations on Sequence
User aaaaajack
Language C++14 (GCC 5.4.1)
Score 1400
Code Size 671 Byte
Status AC
Exec Time 331 ms
Memory 9472 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:10:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&q);
                     ^
./Main.cpp:13:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i]);
                      ^

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 103 ms 9344 KB
02.txt AC 109 ms 9472 KB
03.txt AC 104 ms 9472 KB
04.txt AC 108 ms 9472 KB
05.txt AC 103 ms 9472 KB
06.txt AC 216 ms 9472 KB
07.txt AC 256 ms 9472 KB
08.txt AC 246 ms 9472 KB
09.txt AC 238 ms 9472 KB
10.txt AC 222 ms 9472 KB
11.txt AC 205 ms 9472 KB
12.txt AC 243 ms 9472 KB
13.txt AC 240 ms 9472 KB
14.txt AC 211 ms 9472 KB
15.txt AC 207 ms 9472 KB
16.txt AC 225 ms 9472 KB
17.txt AC 234 ms 9472 KB
18.txt AC 219 ms 9472 KB
19.txt AC 199 ms 9472 KB
20.txt AC 227 ms 9472 KB
21.txt AC 331 ms 8192 KB
22.txt AC 308 ms 9216 KB
23.txt AC 269 ms 9472 KB
24.txt AC 107 ms 9344 KB
25.txt AC 104 ms 9216 KB
26.txt AC 108 ms 8320 KB
27.txt AC 86 ms 8192 KB
28.txt AC 84 ms 8192 KB
29.txt AC 83 ms 8192 KB
30.txt AC 85 ms 8192 KB
31.txt AC 4 ms 256 KB
32.txt AC 64 ms 7424 KB
33.txt AC 4 ms 256 KB
34.txt AC 74 ms 8704 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