Submission #847108


Source Code Expand

Copy
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
	#define debug(...) printf(__VA_ARGS__)
#else
	#define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

typedef pair<ll,ll> PLL;

const int MAXN=100050;
const int MAXQ=100050;
VI q;

ll ans[MAXN];

int main() {
	int N, Q; scanf("%d%d",&N,&Q);
	q.PB(N);
	for(int i=0;i<Q;i++) {
		int in;
		scanf("%d",&in);
		while(SZ(q)>0 && q.back()>=in) q.pop_back();
		q.PB(in);
	}
	priority_queue<PLL> pq;
	pq.push(MP(q.back(), 1));
	for(int i=SZ(q)-1;i>=0;i--) {
		while(pq.top().F>q[i]) {
			auto p=pq.top(); pq.pop();
			debug(" [%lld, %lld]\n",p.F,p.S);
			pq.push( MP(q[i], (p.F/q[i])*p.S) );
			if(ll t=p.F%q[i]) 
				pq.push( MP(t, 1*p.S) );
		}
	}
	while(!pq.empty()) {
		auto p=pq.top(); pq.pop();
		ans[1]+=p.S;
		ans[p.F+1]-=p.S;
	}
	for(int i=1;i<=N;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 t1016d
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1143 Byte
Status WA
Exec Time 2118 ms
Memory 65900 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:27:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  int N, Q; scanf("%d%d",&N,&Q);
                               ^
./Main.cpp:31:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d",&in);
                  ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 1400
Status
AC × 2
AC × 10
WA × 1
TLE × 23
RE × 4
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 TLE 2109 ms 65888 KB
02.txt TLE 2109 ms 65888 KB
03.txt TLE 2106 ms 65888 KB
04.txt TLE 2118 ms 65888 KB
05.txt TLE 2106 ms 65888 KB
06.txt TLE 2106 ms 65888 KB
07.txt TLE 2109 ms 65888 KB
08.txt TLE 2109 ms 65888 KB
09.txt TLE 2106 ms 65888 KB
10.txt TLE 2106 ms 65888 KB
11.txt TLE 2106 ms 65888 KB
12.txt TLE 2109 ms 65888 KB
13.txt TLE 2109 ms 65888 KB
14.txt TLE 2109 ms 65888 KB
15.txt TLE 2109 ms 65888 KB
16.txt TLE 2109 ms 65888 KB
17.txt TLE 2106 ms 65888 KB
18.txt TLE 2106 ms 65888 KB
19.txt TLE 2106 ms 65888 KB
20.txt TLE 2106 ms 65888 KB
21.txt TLE 2106 ms 65900 KB
22.txt TLE 2109 ms 65900 KB
23.txt TLE 2106 ms 65888 KB
24.txt RE 384 ms 640 KB
25.txt RE 212 ms 512 KB
26.txt RE 210 ms 640 KB
27.txt AC 35 ms 1152 KB
28.txt AC 35 ms 1152 KB
29.txt AC 35 ms 1152 KB
30.txt AC 36 ms 1152 KB
31.txt AC 4 ms 256 KB
32.txt AC 19 ms 1152 KB
33.txt AC 4 ms 256 KB
34.txt RE 189 ms 256 KB
35.txt AC 4 ms 256 KB
36.txt WA 4 ms 256 KB
s1.txt AC 4 ms 256 KB
s2.txt AC 4 ms 256 KB