답안 #210448

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
210448 2020-03-17T11:35:14 Z mhy908 Naan (JOI19_naan) C++14
100 / 100
631 ms 116852 KB
#include <bits/stdc++.h>
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<LL, LL> pll;
const LL llinf=1987654321987654321;
int n, m, pr[2010];
pll ans[2010][2010];
LL arr[2010][2010];
bool ch[2010];
bool operator<(pll a, pll b){
    return (__int128)a.F*b.S<(__int128)a.S*b.F;
}
int main(){
    scanf("%d %d", &n, &m);
    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++)scanf("%lld", &arr[i][j]);
    }
    for(int i=1; i<=n; i++){
        LL sum=0, temp=arr[i][1];
        int pv=1;
        for(int j=1; j<=m; j++)sum+=arr[i][j];
        for(int j=1; j<=n; j++){
            while(temp*n<sum*j)temp+=arr[i][++pv];
            ans[i][j]=mp(sum*j+arr[i][pv]*n*pv-temp*n, arr[i][pv]*n);
        }
    }

    for(int i=1; i<n; i++){
        pll minn=mp(llinf, 1ll);
        int temp;
        for(int j=1; j<=n; j++){
            if(!ch[j]&&ans[j][i]<minn){
                temp=j;
                minn=ans[j][i];
            }
        }
        ch[temp]=true;
        pr[i]=temp;
        printf("%lld %lld\n", minn.F, minn.S);
    }
    for(int i=1; i<n; i++)printf("%d ", pr[i]);
    for(int i=1; i<=n; i++){
        if(!ch[i])printf("%d", i);
    }
}

Compilation message

naan.cpp: In function 'int main()':
naan.cpp:17:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
     ~~~~~^~~~~~~~~~~~~~~~~
naan.cpp:19:37: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         for(int j=1; j<=m; j++)scanf("%lld", &arr[i][j]);
                                ~~~~~^~~~~~~~~~~~~~~~~~~~
naan.cpp:40:17: warning: 'temp' may be used uninitialized in this function [-Wmaybe-uninitialized]
         ch[temp]=true;
         ~~~~~~~~^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 7 ms 376 KB Output is correct
4 Correct 6 ms 508 KB Output is correct
5 Correct 6 ms 504 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 6 ms 504 KB Output is correct
10 Correct 6 ms 504 KB Output is correct
11 Correct 5 ms 376 KB Output is correct
12 Correct 5 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 ms 504 KB Output is correct
15 Correct 6 ms 504 KB Output is correct
16 Correct 6 ms 504 KB Output is correct
17 Correct 6 ms 504 KB Output is correct
18 Correct 6 ms 504 KB Output is correct
19 Correct 6 ms 504 KB Output is correct
20 Correct 6 ms 504 KB Output is correct
21 Correct 6 ms 504 KB Output is correct
22 Correct 6 ms 504 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 6 ms 504 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 6 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 5 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 6 ms 376 KB Output is correct
12 Correct 6 ms 376 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 5 ms 376 KB Output is correct
15 Correct 5 ms 376 KB Output is correct
16 Correct 5 ms 376 KB Output is correct
17 Correct 5 ms 376 KB Output is correct
18 Correct 7 ms 376 KB Output is correct
19 Correct 6 ms 508 KB Output is correct
20 Correct 6 ms 504 KB Output is correct
21 Correct 5 ms 376 KB Output is correct
22 Correct 5 ms 376 KB Output is correct
23 Correct 5 ms 376 KB Output is correct
24 Correct 6 ms 504 KB Output is correct
25 Correct 6 ms 504 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 5 ms 376 KB Output is correct
28 Correct 5 ms 376 KB Output is correct
29 Correct 6 ms 504 KB Output is correct
30 Correct 6 ms 504 KB Output is correct
31 Correct 6 ms 504 KB Output is correct
32 Correct 6 ms 504 KB Output is correct
33 Correct 6 ms 504 KB Output is correct
34 Correct 6 ms 504 KB Output is correct
35 Correct 6 ms 504 KB Output is correct
36 Correct 6 ms 504 KB Output is correct
37 Correct 6 ms 504 KB Output is correct
38 Correct 5 ms 376 KB Output is correct
39 Correct 6 ms 504 KB Output is correct
40 Correct 5 ms 376 KB Output is correct
41 Correct 5 ms 376 KB Output is correct
42 Correct 6 ms 504 KB Output is correct
43 Correct 51 ms 13432 KB Output is correct
44 Correct 289 ms 63864 KB Output is correct
45 Correct 200 ms 28920 KB Output is correct
46 Correct 34 ms 4088 KB Output is correct
47 Correct 227 ms 42488 KB Output is correct
48 Correct 167 ms 75384 KB Output is correct
49 Correct 75 ms 24160 KB Output is correct
50 Correct 342 ms 95736 KB Output is correct
51 Correct 202 ms 41720 KB Output is correct
52 Correct 400 ms 87032 KB Output is correct
53 Correct 299 ms 80888 KB Output is correct
54 Correct 5 ms 376 KB Output is correct
55 Correct 52 ms 44024 KB Output is correct
56 Correct 251 ms 56440 KB Output is correct
57 Correct 196 ms 49272 KB Output is correct
58 Correct 255 ms 78584 KB Output is correct
59 Correct 236 ms 46072 KB Output is correct
60 Correct 620 ms 116600 KB Output is correct
61 Correct 631 ms 116592 KB Output is correct
62 Correct 601 ms 116332 KB Output is correct
63 Correct 610 ms 116852 KB Output is correct
64 Correct 619 ms 116660 KB Output is correct
65 Correct 477 ms 103404 KB Output is correct
66 Correct 481 ms 103416 KB Output is correct
67 Correct 489 ms 103440 KB Output is correct
68 Correct 232 ms 60268 KB Output is correct
69 Correct 296 ms 56692 KB Output is correct
70 Correct 263 ms 72124 KB Output is correct
71 Correct 414 ms 82256 KB Output is correct