# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
254031 | 2020-07-29T09:16:25 Z | TadijaSebez | Naan (JOI19_naan) | C++11 | 151 ms | 129400 KB |
#include <bits/stdc++.h> using namespace std; #define ll long long const int N=2005; struct frac{ ll p,q; frac(){p=0;q=1;} frac(ll a,ll b=1){if(b<0)a=-a,b=-b;ll g=__gcd(abs(a),b);a/=g;b/=g;p=a;q=b;} frac operator * (ll b) const {return frac(p*b,q);} frac operator - (frac b) const {return frac(p*b.q-b.p*q,q*b.q);} frac operator + (frac b) const {return frac(p*b.q+b.p*q,q*b.q);} frac operator * (frac b) const {return frac(p*b.p,q*b.q);} frac operator / (frac b) const {return frac(p*b.q,q*b.p);} bool operator < (frac b) const {return p*b.q<b.p*q;} void print(){printf("(%lld/%lld)",p,q);} }p[N][N]; frac operator -= (frac&a,frac b){a=a-b;} int v[N][N],sum[N],ans[N]; bool was[N]; int main(){ int n,l; scanf("%i %i",&n,&l); for(int i=1;i<=n;i++){ for(int j=1;j<=l;j++){ scanf("%i",&v[i][j]); sum[i]+=v[i][j]; v[i][j]*=n; } int take=0; for(int j=1,ptr=1;j<=n;j++){ int need=sum[i]; while(v[i][ptr]-take<need){ need-=v[i][ptr]-take; take=0; ptr++; } p[i][j]=frac(ptr-1)+frac(take+need,v[i][ptr]); take+=need; assert(p[i][j-1]<p[i][j]); } } for(int i=1;i<=n;i++){ frac mn=frac(l+1); int k; for(int j=1;j<=n;j++)if(!was[j]){ if(p[j][i]<mn){ mn=p[j][i]; k=j; } } if(i!=n)printf("%lld %lld\n",mn.p,mn.q); ans[i]=k; was[k]=1; } for(int i=1;i<=n;i++)printf("%i ",ans[i]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 63224 KB | Output is correct |
2 | Correct | 36 ms | 63240 KB | Output is correct |
3 | Correct | 32 ms | 63232 KB | Output is correct |
4 | Correct | 35 ms | 63232 KB | Output is correct |
5 | Correct | 30 ms | 63224 KB | Output is correct |
6 | Correct | 34 ms | 63232 KB | Output is correct |
7 | Correct | 30 ms | 63232 KB | Output is correct |
8 | Correct | 34 ms | 63224 KB | Output is correct |
9 | Correct | 30 ms | 63232 KB | Output is correct |
10 | Correct | 35 ms | 63224 KB | Output is correct |
11 | Correct | 30 ms | 63232 KB | Output is correct |
12 | Correct | 34 ms | 63232 KB | Output is correct |
13 | Correct | 30 ms | 63228 KB | Output is correct |
14 | Correct | 35 ms | 63228 KB | Output is correct |
15 | Correct | 30 ms | 63232 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 33 ms | 63224 KB | Output is correct |
2 | Correct | 30 ms | 63232 KB | Output is correct |
3 | Correct | 35 ms | 63360 KB | Output is correct |
4 | Correct | 30 ms | 63352 KB | Output is correct |
5 | Correct | 30 ms | 63360 KB | Output is correct |
6 | Correct | 31 ms | 63232 KB | Output is correct |
7 | Correct | 29 ms | 63224 KB | Output is correct |
8 | Correct | 29 ms | 63232 KB | Output is correct |
9 | Correct | 36 ms | 63352 KB | Output is correct |
10 | Correct | 31 ms | 63352 KB | Output is correct |
11 | Correct | 35 ms | 63352 KB | Output is correct |
12 | Correct | 31 ms | 63224 KB | Output is correct |
13 | Correct | 29 ms | 63268 KB | Output is correct |
14 | Correct | 30 ms | 63352 KB | Output is correct |
15 | Correct | 30 ms | 63360 KB | Output is correct |
16 | Correct | 35 ms | 63352 KB | Output is correct |
17 | Correct | 31 ms | 63360 KB | Output is correct |
18 | Correct | 30 ms | 63360 KB | Output is correct |
19 | Correct | 31 ms | 63360 KB | Output is correct |
20 | Correct | 31 ms | 63360 KB | Output is correct |
21 | Correct | 32 ms | 63356 KB | Output is correct |
22 | Correct | 31 ms | 63352 KB | Output is correct |
23 | Correct | 30 ms | 63248 KB | Output is correct |
24 | Correct | 31 ms | 63352 KB | Output is correct |
25 | Correct | 31 ms | 63224 KB | Output is correct |
26 | Correct | 30 ms | 63224 KB | Output is correct |
27 | Correct | 30 ms | 63224 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 43 ms | 63224 KB | Output is correct |
2 | Correct | 36 ms | 63240 KB | Output is correct |
3 | Correct | 32 ms | 63232 KB | Output is correct |
4 | Correct | 35 ms | 63232 KB | Output is correct |
5 | Correct | 30 ms | 63224 KB | Output is correct |
6 | Correct | 34 ms | 63232 KB | Output is correct |
7 | Correct | 30 ms | 63232 KB | Output is correct |
8 | Correct | 34 ms | 63224 KB | Output is correct |
9 | Correct | 30 ms | 63232 KB | Output is correct |
10 | Correct | 35 ms | 63224 KB | Output is correct |
11 | Correct | 30 ms | 63232 KB | Output is correct |
12 | Correct | 34 ms | 63232 KB | Output is correct |
13 | Correct | 30 ms | 63228 KB | Output is correct |
14 | Correct | 35 ms | 63228 KB | Output is correct |
15 | Correct | 30 ms | 63232 KB | Output is correct |
16 | Correct | 33 ms | 63224 KB | Output is correct |
17 | Correct | 30 ms | 63232 KB | Output is correct |
18 | Correct | 35 ms | 63360 KB | Output is correct |
19 | Correct | 30 ms | 63352 KB | Output is correct |
20 | Correct | 30 ms | 63360 KB | Output is correct |
21 | Correct | 31 ms | 63232 KB | Output is correct |
22 | Correct | 29 ms | 63224 KB | Output is correct |
23 | Correct | 29 ms | 63232 KB | Output is correct |
24 | Correct | 36 ms | 63352 KB | Output is correct |
25 | Correct | 31 ms | 63352 KB | Output is correct |
26 | Correct | 35 ms | 63352 KB | Output is correct |
27 | Correct | 31 ms | 63224 KB | Output is correct |
28 | Correct | 29 ms | 63268 KB | Output is correct |
29 | Correct | 30 ms | 63352 KB | Output is correct |
30 | Correct | 30 ms | 63360 KB | Output is correct |
31 | Correct | 35 ms | 63352 KB | Output is correct |
32 | Correct | 31 ms | 63360 KB | Output is correct |
33 | Correct | 30 ms | 63360 KB | Output is correct |
34 | Correct | 31 ms | 63360 KB | Output is correct |
35 | Correct | 31 ms | 63360 KB | Output is correct |
36 | Correct | 32 ms | 63356 KB | Output is correct |
37 | Correct | 31 ms | 63352 KB | Output is correct |
38 | Correct | 30 ms | 63248 KB | Output is correct |
39 | Correct | 31 ms | 63352 KB | Output is correct |
40 | Correct | 31 ms | 63224 KB | Output is correct |
41 | Correct | 30 ms | 63224 KB | Output is correct |
42 | Correct | 30 ms | 63224 KB | Output is correct |
43 | Correct | 151 ms | 66560 KB | Output is correct |
44 | Runtime error | 142 ms | 129400 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
45 | Halted | 0 ms | 0 KB | - |