답안 #210454

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
210454 2020-03-17T11:41:04 Z mhy908 Naan (JOI19_naan) C++14
100 / 100
635 ms 96248 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;
        if(i<n)printf("%lld %lld\n", minn.F, minn.S);
    }
    for(int i=1; i<=n; i++)printf("%d ", pr[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 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 380 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 5 ms 376 KB Output is correct
12 Correct 5 ms 380 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 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 5 ms 504 KB Output is correct
4 Correct 6 ms 504 KB Output is correct
5 Correct 5 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 504 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 508 KB Output is correct
19 Correct 6 ms 504 KB Output is correct
20 Correct 6 ms 376 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 376 KB Output is correct
25 Correct 5 ms 376 KB Output is correct
26 Correct 5 ms 376 KB Output is correct
27 Correct 7 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 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 380 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 5 ms 376 KB Output is correct
12 Correct 5 ms 380 KB Output is correct
13 Correct 5 ms 376 KB Output is correct
14 Correct 6 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 5 ms 504 KB Output is correct
19 Correct 6 ms 504 KB Output is correct
20 Correct 5 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 504 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 508 KB Output is correct
34 Correct 6 ms 504 KB Output is correct
35 Correct 6 ms 376 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 376 KB Output is correct
40 Correct 5 ms 376 KB Output is correct
41 Correct 5 ms 376 KB Output is correct
42 Correct 7 ms 376 KB Output is correct
43 Correct 50 ms 13428 KB Output is correct
44 Correct 292 ms 55928 KB Output is correct
45 Correct 203 ms 24056 KB Output is correct
46 Correct 34 ms 4088 KB Output is correct
47 Correct 225 ms 36984 KB Output is correct
48 Correct 154 ms 75384 KB Output is correct
49 Correct 70 ms 24056 KB Output is correct
50 Correct 341 ms 93152 KB Output is correct
51 Correct 203 ms 41080 KB Output is correct
52 Correct 386 ms 82684 KB Output is correct
53 Correct 291 ms 78968 KB Output is correct
54 Correct 5 ms 376 KB Output is correct
55 Correct 53 ms 44152 KB Output is correct
56 Correct 246 ms 55036 KB Output is correct
57 Correct 214 ms 49120 KB Output is correct
58 Correct 256 ms 77816 KB Output is correct
59 Correct 229 ms 44920 KB Output is correct
60 Correct 627 ms 94968 KB Output is correct
61 Correct 613 ms 94836 KB Output is correct
62 Correct 628 ms 94584 KB Output is correct
63 Correct 613 ms 94968 KB Output is correct
64 Correct 635 ms 94968 KB Output is correct
65 Correct 480 ms 96120 KB Output is correct
66 Correct 479 ms 96248 KB Output is correct
67 Correct 490 ms 95864 KB Output is correct
68 Correct 229 ms 55032 KB Output is correct
69 Correct 280 ms 48888 KB Output is correct
70 Correct 249 ms 65784 KB Output is correct
71 Correct 401 ms 71288 KB Output is correct