# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
379063 | 2021-03-17T08:53:29 Z | urd05 | Naan (JOI19_naan) | C++14 | 763 ms | 100844 KB |
#include <bits/stdc++.h> using namespace std; int arr[2000][2000]; typedef pair<long long,long long> P; //first/second typedef pair<P,int> Pi; bool used[2000]; bool comp(Pi a,Pi b) { return (__int128)a.first.first*b.first.second<(__int128)b.first.first*a.first.second; } P save[2000][2000]; int main(void) { int n,l; scanf("%d %d",&n,&l); for(int i=0;i<n;i++) { for(int j=0;j<l;j++) { scanf("%d",&arr[i][j]); } } for(int i=0;i<n;i++) { int ind=1; long long sum=0; for(int j=0;j<l;j++) { sum+=arr[i][j]; } long long temp=0; for(int j=0;j<l;j++) { while (ind<n&&(temp+arr[i][j])*n>=sum*ind) { save[i][ind]=P(sum*ind-n*temp+j*1LL*n*arr[i][j],n*arr[i][j]); ind++; } temp+=arr[i][j]; } } vector<P> ret; vector<int> v; for(int cnt=n-1;cnt>0;cnt--) { vector<Pi> vec; for(int i=0;i<n;i++) { if (!used[i]) { vec.push_back(Pi(save[i][cnt],i)); } } sort(vec.begin(),vec.end(),comp); reverse(vec.begin(),vec.end()); used[vec[0].second]=true; v.push_back(vec[0].second); ret.push_back(vec[0].first); } reverse(ret.begin(),ret.end()); for(int i=0;i<n;i++) { if (!used[i]) { v.push_back(i); } } reverse(v.begin(),v.end()); for(int i=0;i<ret.size();i++) { printf("%lld %lld\n",ret[i].first,ret[i].second); } for(int i=0;i<v.size();i++) { printf("%d ",v[i]+1); } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 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 | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 2 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 2 ms | 364 KB | Output is correct |
5 | Correct | 2 ms | 512 KB | Output is correct |
6 | Correct | 1 ms | 364 KB | Output is correct |
7 | Correct | 1 ms | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 3 ms | 492 KB | Output is correct |
10 | Correct | 2 ms | 512 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 2 ms | 364 KB | Output is correct |
15 | Correct | 2 ms | 364 KB | Output is correct |
16 | Correct | 2 ms | 364 KB | Output is correct |
17 | Correct | 2 ms | 364 KB | Output is correct |
18 | Correct | 2 ms | 364 KB | Output is correct |
19 | Correct | 2 ms | 364 KB | Output is correct |
20 | Correct | 2 ms | 364 KB | Output is correct |
21 | Correct | 2 ms | 364 KB | Output is correct |
22 | Correct | 2 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 2 ms | 364 KB | Output is correct |
25 | Correct | 1 ms | 364 KB | Output is correct |
26 | Correct | 1 ms | 364 KB | Output is correct |
27 | Correct | 3 ms | 364 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 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 | 364 KB | Output is correct |
8 | Correct | 1 ms | 364 KB | Output is correct |
9 | Correct | 1 ms | 364 KB | Output is correct |
10 | Correct | 1 ms | 364 KB | Output is correct |
11 | Correct | 1 ms | 364 KB | Output is correct |
12 | Correct | 1 ms | 364 KB | Output is correct |
13 | Correct | 1 ms | 364 KB | Output is correct |
14 | Correct | 1 ms | 364 KB | Output is correct |
15 | Correct | 1 ms | 364 KB | Output is correct |
16 | Correct | 1 ms | 364 KB | Output is correct |
17 | Correct | 2 ms | 364 KB | Output is correct |
18 | Correct | 1 ms | 364 KB | Output is correct |
19 | Correct | 2 ms | 364 KB | Output is correct |
20 | Correct | 2 ms | 512 KB | Output is correct |
21 | Correct | 1 ms | 364 KB | Output is correct |
22 | Correct | 1 ms | 364 KB | Output is correct |
23 | Correct | 1 ms | 364 KB | Output is correct |
24 | Correct | 3 ms | 492 KB | Output is correct |
25 | Correct | 2 ms | 512 KB | Output is correct |
26 | Correct | 1 ms | 364 KB | Output is correct |
27 | Correct | 1 ms | 364 KB | Output is correct |
28 | Correct | 1 ms | 364 KB | Output is correct |
29 | Correct | 2 ms | 364 KB | Output is correct |
30 | Correct | 2 ms | 364 KB | Output is correct |
31 | Correct | 2 ms | 364 KB | Output is correct |
32 | Correct | 2 ms | 364 KB | Output is correct |
33 | Correct | 2 ms | 364 KB | Output is correct |
34 | Correct | 2 ms | 364 KB | Output is correct |
35 | Correct | 2 ms | 364 KB | Output is correct |
36 | Correct | 2 ms | 364 KB | Output is correct |
37 | Correct | 2 ms | 364 KB | Output is correct |
38 | Correct | 1 ms | 364 KB | Output is correct |
39 | Correct | 2 ms | 364 KB | Output is correct |
40 | Correct | 1 ms | 364 KB | Output is correct |
41 | Correct | 1 ms | 364 KB | Output is correct |
42 | Correct | 3 ms | 364 KB | Output is correct |
43 | Correct | 84 ms | 11756 KB | Output is correct |
44 | Correct | 384 ms | 55612 KB | Output is correct |
45 | Correct | 211 ms | 23404 KB | Output is correct |
46 | Correct | 26 ms | 3052 KB | Output is correct |
47 | Correct | 299 ms | 35232 KB | Output is correct |
48 | Correct | 424 ms | 71928 KB | Output is correct |
49 | Correct | 183 ms | 22296 KB | Output is correct |
50 | Correct | 751 ms | 83052 KB | Output is correct |
51 | Correct | 292 ms | 33412 KB | Output is correct |
52 | Correct | 601 ms | 73696 KB | Output is correct |
53 | Correct | 489 ms | 69824 KB | Output is correct |
54 | Correct | 2 ms | 364 KB | Output is correct |
55 | Correct | 186 ms | 43628 KB | Output is correct |
56 | Correct | 361 ms | 46316 KB | Output is correct |
57 | Correct | 291 ms | 40812 KB | Output is correct |
58 | Correct | 460 ms | 69776 KB | Output is correct |
59 | Correct | 325 ms | 37484 KB | Output is correct |
60 | Correct | 763 ms | 100588 KB | Output is correct |
61 | Correct | 690 ms | 100716 KB | Output is correct |
62 | Correct | 735 ms | 100548 KB | Output is correct |
63 | Correct | 728 ms | 100844 KB | Output is correct |
64 | Correct | 711 ms | 100716 KB | Output is correct |
65 | Correct | 626 ms | 87344 KB | Output is correct |
66 | Correct | 615 ms | 87660 KB | Output is correct |
67 | Correct | 655 ms | 87460 KB | Output is correct |
68 | Correct | 282 ms | 52544 KB | Output is correct |
69 | Correct | 338 ms | 46828 KB | Output is correct |
70 | Correct | 330 ms | 64236 KB | Output is correct |
71 | Correct | 483 ms | 69780 KB | Output is correct |