답안 #152289

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
152289 2019-09-07T03:32:55 Z username Naan (JOI19_naan) C++14
100 / 100
578 ms 102616 KB
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define int int64_t
using namespace std;
typedef pair<int,int> 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];
pii c[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];
	}
	REP(i,0,n){
		int ptr=0;
		REP(j,1,n){
			while(v[i][ptr+1]*n<=v[i][l]*j)++ptr;
			int k=(v[i][ptr+1]-v[i][ptr])*n;
			c[i][j]={k*ptr+v[i][l]*j-v[i][ptr]*n,k};
		}
	}
	REP(i,1,n){
		int opt=-1;
		REP(j,0,n){
			if(us[j])continue;
			if(opt<0||(__int128)c[j][i].f*c[opt][i].s<(__int128)c[opt][i].f*c[j][i].s)opt=j;
		}
		p[i]=opt;
		us[opt]=1;
		cout<<c[opt][i].f<<" "<<c[opt][i].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:17:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 380 KB Output is correct
3 Correct 3 ms 380 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 3 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 2 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 3 ms 504 KB Output is correct
5 Correct 3 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 348 KB Output is correct
8 Correct 3 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 504 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 504 KB Output is correct
15 Correct 3 ms 504 KB Output is correct
16 Correct 3 ms 504 KB Output is correct
17 Correct 3 ms 508 KB Output is correct
18 Correct 3 ms 504 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 504 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 376 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 3 ms 376 KB Output is correct
27 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 380 KB Output is correct
3 Correct 3 ms 380 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 3 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 3 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 2 ms 380 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 504 KB Output is correct
20 Correct 3 ms 376 KB Output is correct
21 Correct 2 ms 376 KB Output is correct
22 Correct 2 ms 348 KB Output is correct
23 Correct 3 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 504 KB Output is correct
27 Correct 2 ms 376 KB Output is correct
28 Correct 3 ms 376 KB Output is correct
29 Correct 3 ms 504 KB Output is correct
30 Correct 3 ms 504 KB Output is correct
31 Correct 3 ms 504 KB Output is correct
32 Correct 3 ms 508 KB Output is correct
33 Correct 3 ms 504 KB Output is correct
34 Correct 3 ms 504 KB Output is correct
35 Correct 3 ms 504 KB Output is correct
36 Correct 3 ms 504 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 376 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 3 ms 376 KB Output is correct
42 Correct 3 ms 376 KB Output is correct
43 Correct 46 ms 12488 KB Output is correct
44 Correct 262 ms 58748 KB Output is correct
45 Correct 245 ms 24996 KB Output is correct
46 Correct 26 ms 2936 KB Output is correct
47 Correct 196 ms 41632 KB Output is correct
48 Correct 167 ms 74964 KB Output is correct
49 Correct 66 ms 23288 KB Output is correct
50 Correct 319 ms 93020 KB Output is correct
51 Correct 166 ms 40804 KB Output is correct
52 Correct 355 ms 86376 KB Output is correct
53 Correct 259 ms 80676 KB Output is correct
54 Correct 3 ms 376 KB Output is correct
55 Correct 73 ms 43896 KB Output is correct
56 Correct 210 ms 54384 KB Output is correct
57 Correct 169 ms 48760 KB Output is correct
58 Correct 236 ms 78584 KB Output is correct
59 Correct 191 ms 45888 KB Output is correct
60 Correct 578 ms 98932 KB Output is correct
61 Correct 538 ms 97804 KB Output is correct
62 Correct 537 ms 97656 KB Output is correct
63 Correct 547 ms 97884 KB Output is correct
64 Correct 545 ms 97808 KB Output is correct
65 Correct 407 ms 102616 KB Output is correct
66 Correct 403 ms 102512 KB Output is correct
67 Correct 405 ms 102176 KB Output is correct
68 Correct 227 ms 60168 KB Output is correct
69 Correct 250 ms 56680 KB Output is correct
70 Correct 236 ms 72136 KB Output is correct
71 Correct 344 ms 77984 KB Output is correct