Submission #1678051
Source Code Expand
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <set>
using namespace std;
#define MAXN 100000
#define ll long long
#define rint register int
#define gc() getchar()
inline ll read(ll ans = 0, rint sgn = ' ', rint ch = gc())
{
for(; ch < '0' || ch > '9'; sgn = ch, ch = gc());
for(; ch >='0' && ch <='9';(ans*=10)+=ch-'0', ch = gc());
return sgn-'-'?ans:-ans;
}
int N, Q; ll X[MAXN+5], R[MAXN+5], x; typedef pair<long long,long long> pll; set<pll> S; set<pll>::iterator c; pll d;
int main()
{
N = read(); X[Q=1] = N; for(int i = read(); i--; X[++Q] = x) for(x = read(); Q && x <= X[Q]; Q--); S.insert(pll(X[Q],1));
for(ll j, coe1, coe2, mod; (d=*--S.end()).first > X[1]; )
{
S.erase(--S.end());
j = lower_bound(X+1,X+Q+1,d.first)-X-1, coe1 = d.first/X[j]*d.second, coe2 = d.second, mod = d.first%X[j];
c = lower_bound(S.begin(),S.end(),pll(X[j],0)), c != S.end() && c->first == X[j] ? coe1 += c->second, S.erase(c),0 : 0;
c = lower_bound(S.begin(),S.end(),pll( mod,0)), c != S.end() && c->first == mod ? coe2 += c->second, S.erase(c),0 : 0;
S.insert(pll(X[j],coe1)), S.insert(pll(mod,coe2));
} for(; S.size(); R[S.begin()->first] = S.begin()->second, S.erase(S.begin()));
for(rint i = N; i; R[i-1] += R[i], i--); for(rint i = 1; i <= N; printf("%lld\n",R[i]), i++); return 0;
}
Submission Info
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
0 / 1400 |
Status |
|
|
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 |
28 ms |
2304 KB |
02.txt |
AC |
29 ms |
2432 KB |
03.txt |
AC |
28 ms |
2432 KB |
04.txt |
AC |
29 ms |
2432 KB |
05.txt |
AC |
29 ms |
2432 KB |
06.txt |
TLE |
2103 ms |
1536 KB |
07.txt |
TLE |
2103 ms |
1536 KB |
08.txt |
TLE |
2103 ms |
1536 KB |
09.txt |
TLE |
2103 ms |
1536 KB |
10.txt |
TLE |
2103 ms |
1536 KB |
11.txt |
TLE |
2103 ms |
1536 KB |
12.txt |
TLE |
2103 ms |
1536 KB |
13.txt |
TLE |
2103 ms |
1536 KB |
14.txt |
TLE |
2103 ms |
1536 KB |
15.txt |
TLE |
2103 ms |
1536 KB |
16.txt |
TLE |
2103 ms |
1536 KB |
17.txt |
TLE |
2103 ms |
1536 KB |
18.txt |
TLE |
2103 ms |
1536 KB |
19.txt |
TLE |
2103 ms |
1536 KB |
20.txt |
TLE |
2103 ms |
1536 KB |
21.txt |
TLE |
2103 ms |
1664 KB |
22.txt |
TLE |
2103 ms |
1664 KB |
23.txt |
TLE |
2103 ms |
1664 KB |
24.txt |
AC |
78 ms |
3072 KB |
25.txt |
AC |
68 ms |
2944 KB |
26.txt |
AC |
69 ms |
2048 KB |
27.txt |
AC |
15 ms |
1280 KB |
28.txt |
AC |
14 ms |
1280 KB |
29.txt |
AC |
14 ms |
1280 KB |
30.txt |
AC |
15 ms |
1280 KB |
31.txt |
AC |
1 ms |
256 KB |
32.txt |
AC |
10 ms |
1280 KB |
33.txt |
AC |
1 ms |
256 KB |
34.txt |
AC |
13 ms |
2432 KB |
35.txt |
AC |
1 ms |
256 KB |
36.txt |
AC |
1 ms |
256 KB |
s1.txt |
AC |
1 ms |
256 KB |
s2.txt |
AC |
1 ms |
256 KB |