답안 #123731

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
123731 2019-07-02T05:46:43 Z 김세빈(#3028) Naan (JOI19_naan) C++14
100 / 100
734 ms 65656 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair <ll, ll> pll;

bool operator < (pll pa, pll pb)
{
	if(pa.first / pa.second != pb.first / pb.second){
		return pa.first / pa.second < pb.first / pb.second;
	}
	else return pa.first % pa.second * pb.second < pb.first % pb.second * pa.second;
}

pll F[2020][2020];
ll V[2020], P[2020];
bool chk[2020];
ll n, m;

int main()
{
	ll i, j, t, k, s, x;
	
	scanf("%lld%lld", &n, &m);
	
	for(i=1; i<=n; i++){
		for(j=1, s=0; j<=m; j++){
			scanf("%lld", V + j);
			s += V[j];
		}
		
		for(j=1, k=1, x=0; j<n; j++){
			x += s;
			for(; k <= m && x >= V[k] * n; k ++) x -= V[k] * n;
			F[i][j] = pll(x + n * V[k] * (k - 1), n * V[k]);
		}
	}
	
	for(i=1; i<=n; i++){
		for(j=1, t=-1; j<=n; j++){
			if(!chk[j] && (t == -1 || F[j][i] < F[t][i])) t = j;
		}
		
		if(i < n) printf("%lld %lld\n", F[t][i].first, F[t][i].second);
		chk[t] = 1; P[i] = t;
	}
	
	for(i=1; i<=n; i++){
		printf("%lld ", P[i]);
	}
	
	printf("\n");
	
	return 0;
}

Compilation message

naan.cpp: In function 'int main()':
naan.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~~~~
naan.cpp:29:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%lld", V + j);
    ~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 380 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 380 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 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 408 KB Output is correct
4 Correct 3 ms 380 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 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 1 ms 376 KB Output is correct
10 Correct 3 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 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 380 KB Output is correct
20 Correct 3 ms 424 KB Output is correct
21 Correct 3 ms 376 KB Output is correct
22 Correct 3 ms 376 KB Output is correct
23 Correct 2 ms 376 KB Output is correct
24 Correct 3 ms 380 KB Output is correct
25 Correct 2 ms 376 KB Output is correct
26 Correct 2 ms 380 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 2 ms 380 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 380 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 380 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 2 ms 376 KB Output is correct
17 Correct 2 ms 376 KB Output is correct
18 Correct 2 ms 408 KB Output is correct
19 Correct 3 ms 380 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 376 KB Output is correct
23 Correct 2 ms 380 KB Output is correct
24 Correct 1 ms 376 KB Output is correct
25 Correct 3 ms 376 KB Output is correct
26 Correct 2 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 380 KB Output is correct
35 Correct 3 ms 424 KB Output is correct
36 Correct 3 ms 376 KB Output is correct
37 Correct 3 ms 376 KB Output is correct
38 Correct 2 ms 376 KB Output is correct
39 Correct 3 ms 380 KB Output is correct
40 Correct 2 ms 376 KB Output is correct
41 Correct 2 ms 380 KB Output is correct
42 Correct 3 ms 376 KB Output is correct
43 Correct 53 ms 9080 KB Output is correct
44 Correct 330 ms 36460 KB Output is correct
45 Correct 203 ms 12840 KB Output is correct
46 Correct 30 ms 2296 KB Output is correct
47 Correct 244 ms 21624 KB Output is correct
48 Correct 215 ms 61432 KB Output is correct
49 Correct 76 ms 16504 KB Output is correct
50 Correct 380 ms 65128 KB Output is correct
51 Correct 197 ms 24824 KB Output is correct
52 Correct 413 ms 55316 KB Output is correct
53 Correct 317 ms 54136 KB Output is correct
54 Correct 3 ms 376 KB Output is correct
55 Correct 97 ms 37112 KB Output is correct
56 Correct 259 ms 34780 KB Output is correct
57 Correct 206 ms 31228 KB Output is correct
58 Correct 293 ms 56000 KB Output is correct
59 Correct 239 ms 27548 KB Output is correct
60 Correct 701 ms 64832 KB Output is correct
61 Correct 704 ms 64664 KB Output is correct
62 Correct 729 ms 64444 KB Output is correct
63 Correct 698 ms 64676 KB Output is correct
64 Correct 734 ms 64652 KB Output is correct
65 Correct 527 ms 65504 KB Output is correct
66 Correct 530 ms 65532 KB Output is correct
67 Correct 531 ms 65656 KB Output is correct
68 Correct 265 ms 38008 KB Output is correct
69 Correct 300 ms 31608 KB Output is correct
70 Correct 301 ms 47624 KB Output is correct
71 Correct 447 ms 47832 KB Output is correct