Submission #1680195


Source Code Expand

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
#include <vector>
#include <map>

using namespace std;
typedef long long LL;
const int maxn = 100005;
map<LL,LL> f[maxn];
map<LL,LL>::iterator it;

LL q[maxn],ans[maxn];int n,m,Q;
int main()
{
	#ifdef Amberframe
		freopen("agc003e.in","r",stdin);
		freopen("agc003e.out","w",stdout);
	#endif
	scanf("%d %d",&n,&Q);q[m=1]=n;
	for (int i=1;i<=Q;i++) {
		LL x;scanf("%d",&x);
		while (m&&q[m]>=x) --m;
		q[++m]=x;
	}
	f[m][q[m]]=1;
	for (int i=m;i>1;i--) {
		it=f[i].begin();LL _=q[i-1];
		for (;it!=f[i].end();it++) {
			LL o=it->first,w=it->second;
			if (o>=_) f[i-1][_]+=w*(o/_);
			if (o%_) f[i-1][o%_]+=w;
		}
	}
	it=f[1].begin();
	for (;it!=f[1].end();it++)
		ans[it->first]+=it->second;
	for (int i=n;i>=1;i--)
		ans[i]+=ans[i+1];
	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 Amberframe
Language C++14 (GCC 5.4.1)
Score 0
Code Size 922 Byte
Status RE
Exec Time 113 ms
Memory 6272 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:23:21: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘LL* {aka long long int*}’ [-Wformat=]
   LL x;scanf("%d",&x);
                     ^
./Main.cpp:21:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d",&n,&Q);q[m=1]=n;
                      ^
./Main.cpp:23:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   LL x;scanf("%d",&x);
                      ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1400
Status
AC × 2
AC × 10
WA × 23
RE × 5
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 29 ms 6144 KB
02.txt WA 28 ms 5888 KB
03.txt WA 29 ms 6144 KB
04.txt WA 28 ms 6016 KB
05.txt WA 29 ms 6144 KB
06.txt WA 28 ms 6016 KB
07.txt WA 28 ms 6016 KB
08.txt WA 29 ms 6144 KB
09.txt WA 29 ms 6144 KB
10.txt WA 28 ms 6016 KB
11.txt WA 28 ms 6016 KB
12.txt WA 29 ms 6272 KB
13.txt WA 28 ms 6016 KB
14.txt WA 28 ms 6016 KB
15.txt WA 28 ms 6016 KB
16.txt WA 28 ms 6016 KB
17.txt WA 28 ms 6016 KB
18.txt WA 29 ms 6272 KB
19.txt WA 28 ms 5888 KB
20.txt WA 28 ms 6016 KB
21.txt RE 110 ms 4992 KB
22.txt WA 25 ms 6016 KB
23.txt RE 113 ms 4992 KB
24.txt RE 109 ms 5504 KB
25.txt RE 109 ms 5248 KB
26.txt RE 108 ms 5632 KB
27.txt AC 20 ms 5888 KB
28.txt AC 20 ms 5888 KB
29.txt AC 20 ms 5888 KB
30.txt AC 21 ms 5888 KB
31.txt AC 3 ms 4992 KB
32.txt AC 11 ms 5888 KB
33.txt AC 2 ms 4992 KB
34.txt WA 12 ms 6272 KB
35.txt AC 3 ms 4992 KB
36.txt WA 3 ms 4992 KB
s1.txt AC 2 ms 4992 KB
s2.txt AC 2 ms 4992 KB