답안 #134584

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
134584 2019-07-23T04:45:16 Z 임유진(#3241) Telegraph (JOI16_telegraph) C++14
10 / 100
1000 ms 504 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long lint;

const lint LINF = 1ll << 60;

int main() {
	ios::sync_with_stdio(false); cin.tie(0);

	int N;
	int A[20], C[20];
	lint ans = LINF;

	cin >> N;
	for(int i = 1; i <= N; i++) cin >> A[i] >> C[i];

	vector<int> v(N);
	for(int i = 1; i <= N; i++) v[i - 1] = i;
	do {
		lint sum = 0ll;
		for(int i = 0; i < N; i++) if(A[v[i]] != v[(i + 1) % N]) sum += C[v[i]];
		ans = min(ans, sum);
	} while(next_permutation(v.begin(), v.end()));

	cout << ans;
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 206 ms 376 KB Output is correct
2 Correct 204 ms 476 KB Output is correct
3 Correct 205 ms 376 KB Output is correct
4 Correct 208 ms 412 KB Output is correct
5 Correct 206 ms 376 KB Output is correct
6 Correct 215 ms 504 KB Output is correct
7 Correct 211 ms 504 KB Output is correct
8 Correct 214 ms 376 KB Output is correct
9 Correct 213 ms 416 KB Output is correct
10 Correct 212 ms 376 KB Output is correct
11 Correct 205 ms 504 KB Output is correct
12 Correct 209 ms 416 KB Output is correct
13 Correct 208 ms 376 KB Output is correct
14 Correct 207 ms 412 KB Output is correct
15 Correct 209 ms 384 KB Output is correct
16 Correct 215 ms 376 KB Output is correct
17 Correct 208 ms 376 KB Output is correct
18 Correct 212 ms 476 KB Output is correct
19 Correct 201 ms 476 KB Output is correct
20 Correct 193 ms 476 KB Output is correct
21 Correct 194 ms 376 KB Output is correct
22 Correct 213 ms 376 KB Output is correct
23 Correct 213 ms 420 KB Output is correct
24 Correct 211 ms 376 KB Output is correct
25 Correct 205 ms 376 KB Output is correct
26 Correct 210 ms 376 KB Output is correct
27 Correct 212 ms 412 KB Output is correct
28 Correct 209 ms 376 KB Output is correct
29 Correct 212 ms 504 KB Output is correct
30 Correct 201 ms 376 KB Output is correct
31 Correct 223 ms 384 KB Output is correct
32 Correct 213 ms 376 KB Output is correct
33 Correct 243 ms 376 KB Output is correct
34 Correct 218 ms 388 KB Output is correct
35 Correct 215 ms 504 KB Output is correct
36 Correct 228 ms 376 KB Output is correct
37 Correct 168 ms 504 KB Output is correct
38 Correct 169 ms 416 KB Output is correct
39 Correct 212 ms 396 KB Output is correct
40 Correct 216 ms 384 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 3 ms 380 KB Output is correct
45 Correct 2 ms 276 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 221 ms 384 KB Output is correct
48 Correct 218 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 206 ms 376 KB Output is correct
2 Correct 204 ms 476 KB Output is correct
3 Correct 205 ms 376 KB Output is correct
4 Correct 208 ms 412 KB Output is correct
5 Correct 206 ms 376 KB Output is correct
6 Correct 215 ms 504 KB Output is correct
7 Correct 211 ms 504 KB Output is correct
8 Correct 214 ms 376 KB Output is correct
9 Correct 213 ms 416 KB Output is correct
10 Correct 212 ms 376 KB Output is correct
11 Correct 205 ms 504 KB Output is correct
12 Correct 209 ms 416 KB Output is correct
13 Correct 208 ms 376 KB Output is correct
14 Correct 207 ms 412 KB Output is correct
15 Correct 209 ms 384 KB Output is correct
16 Correct 215 ms 376 KB Output is correct
17 Correct 208 ms 376 KB Output is correct
18 Correct 212 ms 476 KB Output is correct
19 Correct 201 ms 476 KB Output is correct
20 Correct 193 ms 476 KB Output is correct
21 Correct 194 ms 376 KB Output is correct
22 Correct 213 ms 376 KB Output is correct
23 Correct 213 ms 420 KB Output is correct
24 Correct 211 ms 376 KB Output is correct
25 Correct 205 ms 376 KB Output is correct
26 Correct 210 ms 376 KB Output is correct
27 Correct 212 ms 412 KB Output is correct
28 Correct 209 ms 376 KB Output is correct
29 Correct 212 ms 504 KB Output is correct
30 Correct 201 ms 376 KB Output is correct
31 Correct 223 ms 384 KB Output is correct
32 Correct 213 ms 376 KB Output is correct
33 Correct 243 ms 376 KB Output is correct
34 Correct 218 ms 388 KB Output is correct
35 Correct 215 ms 504 KB Output is correct
36 Correct 228 ms 376 KB Output is correct
37 Correct 168 ms 504 KB Output is correct
38 Correct 169 ms 416 KB Output is correct
39 Correct 212 ms 396 KB Output is correct
40 Correct 216 ms 384 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 3 ms 380 KB Output is correct
45 Correct 2 ms 276 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 221 ms 384 KB Output is correct
48 Correct 218 ms 376 KB Output is correct
49 Execution timed out 1072 ms 376 KB Time limit exceeded
50 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 206 ms 376 KB Output is correct
2 Correct 204 ms 476 KB Output is correct
3 Correct 205 ms 376 KB Output is correct
4 Correct 208 ms 412 KB Output is correct
5 Correct 206 ms 376 KB Output is correct
6 Correct 215 ms 504 KB Output is correct
7 Correct 211 ms 504 KB Output is correct
8 Correct 214 ms 376 KB Output is correct
9 Correct 213 ms 416 KB Output is correct
10 Correct 212 ms 376 KB Output is correct
11 Correct 205 ms 504 KB Output is correct
12 Correct 209 ms 416 KB Output is correct
13 Correct 208 ms 376 KB Output is correct
14 Correct 207 ms 412 KB Output is correct
15 Correct 209 ms 384 KB Output is correct
16 Correct 215 ms 376 KB Output is correct
17 Correct 208 ms 376 KB Output is correct
18 Correct 212 ms 476 KB Output is correct
19 Correct 201 ms 476 KB Output is correct
20 Correct 193 ms 476 KB Output is correct
21 Correct 194 ms 376 KB Output is correct
22 Correct 213 ms 376 KB Output is correct
23 Correct 213 ms 420 KB Output is correct
24 Correct 211 ms 376 KB Output is correct
25 Correct 205 ms 376 KB Output is correct
26 Correct 210 ms 376 KB Output is correct
27 Correct 212 ms 412 KB Output is correct
28 Correct 209 ms 376 KB Output is correct
29 Correct 212 ms 504 KB Output is correct
30 Correct 201 ms 376 KB Output is correct
31 Correct 223 ms 384 KB Output is correct
32 Correct 213 ms 376 KB Output is correct
33 Correct 243 ms 376 KB Output is correct
34 Correct 218 ms 388 KB Output is correct
35 Correct 215 ms 504 KB Output is correct
36 Correct 228 ms 376 KB Output is correct
37 Correct 168 ms 504 KB Output is correct
38 Correct 169 ms 416 KB Output is correct
39 Correct 212 ms 396 KB Output is correct
40 Correct 216 ms 384 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 3 ms 380 KB Output is correct
45 Correct 2 ms 276 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 221 ms 384 KB Output is correct
48 Correct 218 ms 376 KB Output is correct
49 Execution timed out 1072 ms 376 KB Time limit exceeded
50 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 206 ms 376 KB Output is correct
2 Correct 204 ms 476 KB Output is correct
3 Correct 205 ms 376 KB Output is correct
4 Correct 208 ms 412 KB Output is correct
5 Correct 206 ms 376 KB Output is correct
6 Correct 215 ms 504 KB Output is correct
7 Correct 211 ms 504 KB Output is correct
8 Correct 214 ms 376 KB Output is correct
9 Correct 213 ms 416 KB Output is correct
10 Correct 212 ms 376 KB Output is correct
11 Correct 205 ms 504 KB Output is correct
12 Correct 209 ms 416 KB Output is correct
13 Correct 208 ms 376 KB Output is correct
14 Correct 207 ms 412 KB Output is correct
15 Correct 209 ms 384 KB Output is correct
16 Correct 215 ms 376 KB Output is correct
17 Correct 208 ms 376 KB Output is correct
18 Correct 212 ms 476 KB Output is correct
19 Correct 201 ms 476 KB Output is correct
20 Correct 193 ms 476 KB Output is correct
21 Correct 194 ms 376 KB Output is correct
22 Correct 213 ms 376 KB Output is correct
23 Correct 213 ms 420 KB Output is correct
24 Correct 211 ms 376 KB Output is correct
25 Correct 205 ms 376 KB Output is correct
26 Correct 210 ms 376 KB Output is correct
27 Correct 212 ms 412 KB Output is correct
28 Correct 209 ms 376 KB Output is correct
29 Correct 212 ms 504 KB Output is correct
30 Correct 201 ms 376 KB Output is correct
31 Correct 223 ms 384 KB Output is correct
32 Correct 213 ms 376 KB Output is correct
33 Correct 243 ms 376 KB Output is correct
34 Correct 218 ms 388 KB Output is correct
35 Correct 215 ms 504 KB Output is correct
36 Correct 228 ms 376 KB Output is correct
37 Correct 168 ms 504 KB Output is correct
38 Correct 169 ms 416 KB Output is correct
39 Correct 212 ms 396 KB Output is correct
40 Correct 216 ms 384 KB Output is correct
41 Correct 2 ms 376 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 376 KB Output is correct
44 Correct 3 ms 380 KB Output is correct
45 Correct 2 ms 276 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 221 ms 384 KB Output is correct
48 Correct 218 ms 376 KB Output is correct
49 Execution timed out 1072 ms 376 KB Time limit exceeded
50 Halted 0 ms 0 KB -