Submission #848071


Source Code Expand

Copy
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

ll v[101010];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll n,q;
	cin>>n>>q;
	vector<ll> qs;
	qs.push_back(n);
	for (int i=0;i<q;i++){
		ll qq;
		cin>>qq;
		while (qs.size()>0&&qs.back()>=qq) qs.pop_back();
		qs.push_back(qq);
	}
	map<ll, ll> qq;
	qq[qs.back()]=1;
	for (int i=(int)qs.size()-2;i>=0;i--){
		ll t=qs[i];
		//cout<<t<<endl;
		while ((*qq.rbegin()).F>t){
			ll k=(*qq.rbegin()).F;
			ll a=(*qq.rbegin()).S;
			//cout<<k<<" "<<a<<endl;
			qq.erase(k);
			ll wt=k/t;
			qq[t]+=a*wt;
			if (k%t>0){
				qq[k%t]+=a;
			}
		}
	}
	for (auto a:qq){
		v[a.F]+=a.S;
	}
	for (int i=n;i>=0;i--){
		v[i]+=v[i+1];
	}
	for (int i=1;i<=n;i++){
		cout<<v[i]<<"\n";
	}
}

Submission Info

Submission Time
Task E - Sequential operations on Sequence
User Laakeri
Language C++14 (GCC 5.4.1)
Score 1400
Code Size 891 Byte
Status AC
Exec Time 290 ms
Memory 9460 KB

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 54 ms 2304 KB
02.txt AC 55 ms 2432 KB
03.txt AC 55 ms 2432 KB
04.txt AC 54 ms 2432 KB
05.txt AC 55 ms 2432 KB
06.txt AC 209 ms 8052 KB
07.txt AC 250 ms 8180 KB
08.txt AC 224 ms 8180 KB
09.txt AC 232 ms 8052 KB
10.txt AC 206 ms 8052 KB
11.txt AC 195 ms 8180 KB
12.txt AC 234 ms 8052 KB
13.txt AC 237 ms 8180 KB
14.txt AC 205 ms 8052 KB
15.txt AC 196 ms 8052 KB
16.txt AC 228 ms 8052 KB
17.txt AC 224 ms 8180 KB
18.txt AC 212 ms 8052 KB
19.txt AC 186 ms 8052 KB
20.txt AC 218 ms 8180 KB
21.txt AC 290 ms 8180 KB
22.txt AC 288 ms 9076 KB
23.txt AC 205 ms 9460 KB
24.txt AC 64 ms 3188 KB
25.txt AC 65 ms 3060 KB
26.txt AC 54 ms 2164 KB
27.txt AC 30 ms 1280 KB
28.txt AC 30 ms 1280 KB
29.txt AC 30 ms 1280 KB
30.txt AC 32 ms 1280 KB
31.txt AC 4 ms 256 KB
32.txt AC 17 ms 1280 KB
33.txt AC 4 ms 256 KB
34.txt AC 25 ms 2560 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