# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
152267 |
2019-09-07T02:26:14 Z |
username |
Naan (JOI19_naan) |
C++14 |
|
700 ms |
54068 KB |
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define int int64_t
using namespace std;
typedef pair<__int128,__int128> pii;
#define REP(i,j,k) for(int i=(j);i<(k);++i)
#define f first
#define s second
#define endl '\n'
#define IOS cin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false)
const int maxn=2009;
int n,l,p[maxn],v[maxn][maxn];
bitset<maxn>us;
main(){
IOS;
cin>>n>>l;
REP(i,0,n){
v[i][0]=0;
REP(j,0,l)cin>>v[i][j+1],v[i][j+1]+=v[i][j];
}
pii cur={0,1};
REP(i,1,n){
int opt=-1;
pii ls={1,0};
REP(j,0,n){
if(us[j])continue;
int k=cur.f/cur.s;
pii t={v[j][k]*n*cur.s+(v[j][k+1]-v[j][k])*(cur.f%cur.s)*n+v[j][l]*cur.s,n*cur.s};
while(v[j][k+1]*t.s<=t.f)++k;
int vv=v[j][k+1]-v[j][k];
t={k*vv*n+(t.f*n+t.s-1)/t.s-v[j][k]*n,vv*n};
if(t.f*ls.s<ls.f*t.s)opt=j,ls=t;
}
p[i]=opt;
us[opt]=1;
cur=ls;
cout<<(int)ls.f<<" "<<(int)ls.s<<endl;
}
REP(i,1,n)cout<<p[i]+1<<" ";
REP(i,0,n)if(!us[i])cout<<i+1<<endl;
}
Compilation message
naan.cpp:16:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main(){
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
380 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
376 KB |
Output is correct |
3 |
Correct |
3 ms |
380 KB |
Output is correct |
4 |
Correct |
3 ms |
504 KB |
Output is correct |
5 |
Correct |
3 ms |
504 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
3 ms |
504 KB |
Output is correct |
10 |
Correct |
3 ms |
504 KB |
Output is correct |
11 |
Correct |
3 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
2 ms |
376 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
3 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
376 KB |
Output is correct |
17 |
Correct |
3 ms |
376 KB |
Output is correct |
18 |
Correct |
3 ms |
376 KB |
Output is correct |
19 |
Correct |
3 ms |
376 KB |
Output is correct |
20 |
Correct |
3 ms |
504 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
3 ms |
504 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
3 ms |
504 KB |
Output is correct |
25 |
Correct |
2 ms |
376 KB |
Output is correct |
26 |
Correct |
2 ms |
376 KB |
Output is correct |
27 |
Correct |
3 ms |
504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
2 ms |
376 KB |
Output is correct |
12 |
Correct |
2 ms |
376 KB |
Output is correct |
13 |
Correct |
3 ms |
380 KB |
Output is correct |
14 |
Correct |
3 ms |
376 KB |
Output is correct |
15 |
Correct |
2 ms |
376 KB |
Output is correct |
16 |
Correct |
3 ms |
376 KB |
Output is correct |
17 |
Correct |
3 ms |
376 KB |
Output is correct |
18 |
Correct |
3 ms |
380 KB |
Output is correct |
19 |
Correct |
3 ms |
504 KB |
Output is correct |
20 |
Correct |
3 ms |
504 KB |
Output is correct |
21 |
Correct |
3 ms |
376 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
2 ms |
376 KB |
Output is correct |
24 |
Correct |
3 ms |
504 KB |
Output is correct |
25 |
Correct |
3 ms |
504 KB |
Output is correct |
26 |
Correct |
3 ms |
376 KB |
Output is correct |
27 |
Correct |
2 ms |
376 KB |
Output is correct |
28 |
Correct |
2 ms |
376 KB |
Output is correct |
29 |
Correct |
3 ms |
376 KB |
Output is correct |
30 |
Correct |
3 ms |
376 KB |
Output is correct |
31 |
Correct |
3 ms |
376 KB |
Output is correct |
32 |
Correct |
3 ms |
376 KB |
Output is correct |
33 |
Correct |
3 ms |
376 KB |
Output is correct |
34 |
Correct |
3 ms |
376 KB |
Output is correct |
35 |
Correct |
3 ms |
504 KB |
Output is correct |
36 |
Correct |
3 ms |
376 KB |
Output is correct |
37 |
Correct |
3 ms |
504 KB |
Output is correct |
38 |
Correct |
2 ms |
376 KB |
Output is correct |
39 |
Correct |
3 ms |
504 KB |
Output is correct |
40 |
Correct |
2 ms |
376 KB |
Output is correct |
41 |
Correct |
2 ms |
376 KB |
Output is correct |
42 |
Correct |
3 ms |
504 KB |
Output is correct |
43 |
Correct |
50 ms |
5440 KB |
Output is correct |
44 |
Correct |
316 ms |
20728 KB |
Output is correct |
45 |
Correct |
177 ms |
13048 KB |
Output is correct |
46 |
Correct |
26 ms |
2168 KB |
Output is correct |
47 |
Correct |
217 ms |
16860 KB |
Output is correct |
48 |
Correct |
357 ms |
15864 KB |
Output is correct |
49 |
Correct |
97 ms |
8068 KB |
Output is correct |
50 |
Correct |
502 ms |
30276 KB |
Output is correct |
51 |
Correct |
213 ms |
18544 KB |
Output is correct |
52 |
Correct |
466 ms |
28880 KB |
Output is correct |
53 |
Correct |
399 ms |
27148 KB |
Output is correct |
54 |
Correct |
2 ms |
376 KB |
Output is correct |
55 |
Correct |
105 ms |
7392 KB |
Output is correct |
56 |
Correct |
238 ms |
22992 KB |
Output is correct |
57 |
Correct |
202 ms |
20760 KB |
Output is correct |
58 |
Correct |
301 ms |
24872 KB |
Output is correct |
59 |
Correct |
240 ms |
20216 KB |
Output is correct |
60 |
Correct |
662 ms |
32624 KB |
Output is correct |
61 |
Correct |
670 ms |
53808 KB |
Output is correct |
62 |
Correct |
679 ms |
53756 KB |
Output is correct |
63 |
Correct |
700 ms |
54068 KB |
Output is correct |
64 |
Correct |
683 ms |
53880 KB |
Output is correct |
65 |
Correct |
502 ms |
40684 KB |
Output is correct |
66 |
Correct |
544 ms |
40740 KB |
Output is correct |
67 |
Correct |
500 ms |
40580 KB |
Output is correct |
68 |
Correct |
230 ms |
24804 KB |
Output is correct |
69 |
Correct |
270 ms |
27600 KB |
Output is correct |
70 |
Correct |
274 ms |
27084 KB |
Output is correct |
71 |
Correct |
389 ms |
36472 KB |
Output is correct |