Submission #1838134
Source Code Expand
#include <cstdio> #include <iostream> #include <algorithm> using namespace std; typedef long long ll; const int N=100010; int n,q,t; ll b[N],Q[N],a[N],c[N]; inline char nc(){ static char buf[100000],*p1=buf,*p2=buf; return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++; } inline void read(int &x){ char c=nc(); x=0; for(;c>'9'||c<'0';c=nc());for(;c>='0'&&c<='9';x=x*10+c-'0',c=nc()); } inline void read(ll &x){ char c=nc(); x=0; for(;c>'9'||c<'0';c=nc());for(;c>='0'&&c<='9';x=x*10+c-'0',c=nc()); } inline void work(ll x,ll y){ int p=upper_bound(Q,Q+1+t,x)-Q-1; if(!p) a[1]+=y,a[x+1]-=y; else c[p]+=y*(x/Q[p]),work(x%Q[p],y); } int main(){ read(n); read(q); for(int i=1;i<=q;i++) read(b[i]); Q[++t]=b[q]; for(int i=q-1;i;i--){ if(b[i]>=Q[t]) continue; Q[++t]=b[i]; } if(n<Q[t]) Q[++t]=n; reverse(Q+1,Q+1+t); c[t]=1; for(int i=t;i>1;i--) c[i-1]+=c[i]*(Q[i]/Q[i-1]),work(Q[i]%Q[i-1],c[i]); for(int i=1;i<=n;i++) a[i]+=a[i-1]; for(int i=1;i<=Q[1];i++) a[i]+=c[1]; for(int i=1;i<=n;i++) printf("%lld\n",a[i]); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - Sequential operations on Sequence |
User | SBP |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1151 Byte |
Status | RE |
Exec Time | 97 ms |
Memory | 4992 KB |
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 | 16 ms | 3200 KB |
02.txt | AC | 16 ms | 3328 KB |
03.txt | AC | 17 ms | 3328 KB |
04.txt | AC | 16 ms | 3328 KB |
05.txt | AC | 17 ms | 3328 KB |
06.txt | AC | 25 ms | 4864 KB |
07.txt | AC | 27 ms | 4992 KB |
08.txt | AC | 26 ms | 4992 KB |
09.txt | AC | 28 ms | 4864 KB |
10.txt | AC | 25 ms | 4864 KB |
11.txt | AC | 24 ms | 4992 KB |
12.txt | AC | 27 ms | 4864 KB |
13.txt | AC | 28 ms | 4992 KB |
14.txt | AC | 25 ms | 4864 KB |
15.txt | AC | 24 ms | 4864 KB |
16.txt | AC | 26 ms | 4864 KB |
17.txt | AC | 26 ms | 4864 KB |
18.txt | AC | 25 ms | 4864 KB |
19.txt | AC | 24 ms | 4864 KB |
20.txt | AC | 26 ms | 4864 KB |
21.txt | AC | 44 ms | 3712 KB |
22.txt | AC | 24 ms | 4608 KB |
23.txt | AC | 32 ms | 4864 KB |
24.txt | AC | 18 ms | 4736 KB |
25.txt | AC | 18 ms | 4608 KB |
26.txt | AC | 16 ms | 3584 KB |
27.txt | AC | 11 ms | 2048 KB |
28.txt | AC | 11 ms | 2048 KB |
29.txt | AC | 11 ms | 2048 KB |
30.txt | AC | 11 ms | 2048 KB |
31.txt | AC | 1 ms | 256 KB |
32.txt | RE | 97 ms | 256 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 |