# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
375901 | 2021-03-10T08:33:51 Z | daniel920712 | Naan (JOI19_naan) | C++14 | 1433 ms | 164516 KB |
#include <iostream> #include <stdio.h> #include <stdlib.h> #include <vector> #include <algorithm> using namespace std; long long all[2005][2005]; long long sum[2005][2005]={0}; long long tt[2005]={0}; vector < pair < long long , long long > > ans; vector < long long > ans2; bool have[2005]={0}; vector < pair < pair < long long ,long long > , long long > > where[2005]; long long F(long long a,long long b) { if(b==0) return a; return F(b,a%b); } bool cmp(pair < pair < long long ,long long > , long long > a,pair < pair < long long ,long long > , long long > b) { if(a.first.first/a.first.second>b.first.first/b.first.second) return 0; if(a.first.first/a.first.second<b.first.first/b.first.second) return 1; return a.first.first%a.first.second*b.first.second<b.first.first%b.first.second*a.first.second; } int main() { //freopen("03-02.txt","rt",stdin); long long N,M,a,b,x1,y1,x2,y2,c,i,j,ok=1,now=0,z,x3,y3,t; scanf("%lld %lld",&N,&M); for(i=0;i<N;i++) { sum[i][0]=0; for(j=0;j<M;j++) { scanf("%lld",&all[i][j]); sum[i][j]=sum[i][j-1]+all[i][j]; } } for(i=0;i<N;i++) { x1=0; y1=1; now=0; for(j=0;j<M;j++) { while((x1+all[i][j]*y1)*N>=(sum[i][M-1])*(now+1)*y1) { x2=(sum[i][M-1])*(now+1)*y1-x1*N; y2=y1*N*all[i][j]; where[now++].push_back(make_pair(make_pair(x2+j*y2,y2),i)); } x1+=y1*all[i][j]; } } for(i=0;i<N;i++) sort(where[i].begin(),where[i].end(),cmp); x1=0; y1=1; for(i=0;i<N;i++) { ok=0; for(auto j:where[i]) { if(have[j.second]||x1/y1>j.first.first/j.first.second||x1/y1==j.first.first/j.first.second&&(x1%y1*j.first.second)>(j.first.first%j.first.second*y1)) continue; ok=1; x1=j.first.first; y1=j.first.second; have[j.second]=1; ans.push_back(make_pair(j.first.first,j.first.second)); ans2.push_back(j.second); break; } if(!ok) return 1; } for(i=0;i<N-1;i++) printf("%lld %lld\n",ans[i].first,ans[i].second); for(auto i:ans2) printf("%lld ",i+1); //for(i=0;i<N-1;i++) printf("%.10f\n",(double) ans[i].first/(double) ans[i].second); //printf("%lld\n",M); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 1 ms | 492 KB | Output is correct |
4 | Correct | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 492 KB | Output is correct |
12 | Correct | 1 ms | 492 KB | Output is correct |
13 | Correct | 1 ms | 492 KB | Output is correct |
14 | Correct | 1 ms | 492 KB | Output is correct |
15 | Correct | 1 ms | 492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 2 ms | 492 KB | Output is correct |
4 | Correct | 2 ms | 620 KB | Output is correct |
5 | Correct | 1 ms | 492 KB | Output is correct |
6 | Correct | 1 ms | 492 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 2 ms | 620 KB | Output is correct |
10 | Correct | 2 ms | 620 KB | Output is correct |
11 | Correct | 1 ms | 492 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 492 KB | Output is correct |
14 | Correct | 2 ms | 620 KB | Output is correct |
15 | Correct | 2 ms | 620 KB | Output is correct |
16 | Correct | 2 ms | 620 KB | Output is correct |
17 | Correct | 2 ms | 620 KB | Output is correct |
18 | Correct | 2 ms | 620 KB | Output is correct |
19 | Correct | 2 ms | 620 KB | Output is correct |
20 | Correct | 2 ms | 492 KB | Output is correct |
21 | Correct | 3 ms | 620 KB | Output is correct |
22 | Correct | 2 ms | 620 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 2 ms | 492 KB | Output is correct |
25 | Correct | 1 ms | 492 KB | Output is correct |
26 | Correct | 1 ms | 492 KB | Output is correct |
27 | Correct | 2 ms | 492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 492 KB | Output is correct |
3 | Correct | 1 ms | 492 KB | Output is correct |
4 | Correct | 1 ms | 492 KB | Output is correct |
5 | Correct | 1 ms | 364 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 492 KB | Output is correct |
8 | Correct | 1 ms | 492 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 492 KB | Output is correct |
11 | Correct | 1 ms | 492 KB | Output is correct |
12 | Correct | 1 ms | 492 KB | Output is correct |
13 | Correct | 1 ms | 492 KB | Output is correct |
14 | Correct | 1 ms | 492 KB | Output is correct |
15 | Correct | 1 ms | 492 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 1 ms | 492 KB | Output is correct |
18 | Correct | 2 ms | 492 KB | Output is correct |
19 | Correct | 2 ms | 620 KB | Output is correct |
20 | Correct | 1 ms | 492 KB | Output is correct |
21 | Correct | 1 ms | 492 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 492 KB | Output is correct |
24 | Correct | 2 ms | 620 KB | Output is correct |
25 | Correct | 2 ms | 620 KB | Output is correct |
26 | Correct | 1 ms | 492 KB | Output is correct |
27 | Correct | 1 ms | 364 KB | Output is correct |
28 | Correct | 1 ms | 492 KB | Output is correct |
29 | Correct | 2 ms | 620 KB | Output is correct |
30 | Correct | 2 ms | 620 KB | Output is correct |
31 | Correct | 2 ms | 620 KB | Output is correct |
32 | Correct | 2 ms | 620 KB | Output is correct |
33 | Correct | 2 ms | 620 KB | Output is correct |
34 | Correct | 2 ms | 620 KB | Output is correct |
35 | Correct | 2 ms | 492 KB | Output is correct |
36 | Correct | 3 ms | 620 KB | Output is correct |
37 | Correct | 2 ms | 620 KB | Output is correct |
38 | Correct | 1 ms | 364 KB | Output is correct |
39 | Correct | 2 ms | 492 KB | Output is correct |
40 | Correct | 1 ms | 492 KB | Output is correct |
41 | Correct | 1 ms | 492 KB | Output is correct |
42 | Correct | 2 ms | 492 KB | Output is correct |
43 | Correct | 118 ms | 20844 KB | Output is correct |
44 | Correct | 772 ms | 96108 KB | Output is correct |
45 | Correct | 296 ms | 41964 KB | Output is correct |
46 | Correct | 30 ms | 5740 KB | Output is correct |
47 | Correct | 457 ms | 58584 KB | Output is correct |
48 | Correct | 1109 ms | 121212 KB | Output is correct |
49 | Correct | 277 ms | 37396 KB | Output is correct |
50 | Correct | 1433 ms | 155108 KB | Output is correct |
51 | Correct | 501 ms | 75628 KB | Output is correct |
52 | Correct | 1213 ms | 138164 KB | Output is correct |
53 | Correct | 1093 ms | 130156 KB | Output is correct |
54 | Correct | 2 ms | 492 KB | Output is correct |
55 | Correct | 551 ms | 74464 KB | Output is correct |
56 | Correct | 714 ms | 97516 KB | Output is correct |
57 | Correct | 591 ms | 87480 KB | Output is correct |
58 | Correct | 1025 ms | 125904 KB | Output is correct |
59 | Correct | 556 ms | 82028 KB | Output is correct |
60 | Correct | 1146 ms | 160156 KB | Output is correct |
61 | Correct | 1158 ms | 160020 KB | Output is correct |
62 | Correct | 1320 ms | 159468 KB | Output is correct |
63 | Correct | 1243 ms | 159876 KB | Output is correct |
64 | Correct | 1185 ms | 160140 KB | Output is correct |
65 | Correct | 1055 ms | 164204 KB | Output is correct |
66 | Correct | 1056 ms | 164320 KB | Output is correct |
67 | Correct | 1108 ms | 164516 KB | Output is correct |
68 | Correct | 515 ms | 100516 KB | Output is correct |
69 | Correct | 530 ms | 94644 KB | Output is correct |
70 | Correct | 594 ms | 115820 KB | Output is correct |
71 | Correct | 780 ms | 126104 KB | Output is correct |