Submission #134642

# Submission time Handle Problem Language Result Execution time Memory
134642 2019-07-23T06:14:34 Z 이온조(#3239) Telegraph (JOI16_telegraph) C++14
10 / 100
1000 ms 508 KB
#include <bits/stdc++.h>
using namespace std;

const long long INF = 1LL * 1e18;
int A[100009], C[100009];

int main() {
	int N; scanf("%d",&N);
	for(int i=1; i<=N; i++) scanf("%d%d",&A[i],&C[i]);
	vector<int> S;
	for(int i=1; i<=N; i++) S.push_back(i);
	long long ans = INF;
	do {
		long long s = 0;
		for(int i=0; i<N-1; i++) if(A[S[i+1]] != S[i]) s += C[S[i+1]];
		if(A[S[0]] != S[N-1]) s += C[S[0]];
		ans = min(ans, s);
	} while(next_permutation(S.begin(), S.end()));
	printf("%lld", ans);
	return 0;
}

Compilation message

telegraph.cpp: In function 'int main()':
telegraph.cpp:8:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int N; scanf("%d",&N);
         ~~~~~^~~~~~~~~
telegraph.cpp:9:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1; i<=N; i++) scanf("%d%d",&A[i],&C[i]);
                          ~~~~~^~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 91 ms 380 KB Output is correct
2 Correct 89 ms 376 KB Output is correct
3 Correct 92 ms 376 KB Output is correct
4 Correct 92 ms 256 KB Output is correct
5 Correct 91 ms 504 KB Output is correct
6 Correct 96 ms 364 KB Output is correct
7 Correct 95 ms 376 KB Output is correct
8 Correct 96 ms 472 KB Output is correct
9 Correct 95 ms 256 KB Output is correct
10 Correct 96 ms 376 KB Output is correct
11 Correct 90 ms 256 KB Output is correct
12 Correct 93 ms 404 KB Output is correct
13 Correct 92 ms 256 KB Output is correct
14 Correct 92 ms 404 KB Output is correct
15 Correct 96 ms 376 KB Output is correct
16 Correct 93 ms 376 KB Output is correct
17 Correct 91 ms 504 KB Output is correct
18 Correct 92 ms 508 KB Output is correct
19 Correct 88 ms 380 KB Output is correct
20 Correct 82 ms 376 KB Output is correct
21 Correct 82 ms 376 KB Output is correct
22 Correct 96 ms 244 KB Output is correct
23 Correct 96 ms 376 KB Output is correct
24 Correct 94 ms 504 KB Output is correct
25 Correct 90 ms 256 KB Output is correct
26 Correct 93 ms 384 KB Output is correct
27 Correct 94 ms 400 KB Output is correct
28 Correct 93 ms 376 KB Output is correct
29 Correct 95 ms 376 KB Output is correct
30 Correct 88 ms 256 KB Output is correct
31 Correct 91 ms 404 KB Output is correct
32 Correct 92 ms 376 KB Output is correct
33 Correct 96 ms 376 KB Output is correct
34 Correct 95 ms 256 KB Output is correct
35 Correct 97 ms 376 KB Output is correct
36 Correct 95 ms 376 KB Output is correct
37 Correct 64 ms 376 KB Output is correct
38 Correct 63 ms 376 KB Output is correct
39 Correct 95 ms 504 KB Output is correct
40 Correct 93 ms 376 KB Output is correct
41 Correct 2 ms 380 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 256 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 99 ms 404 KB Output is correct
48 Correct 97 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 91 ms 380 KB Output is correct
2 Correct 89 ms 376 KB Output is correct
3 Correct 92 ms 376 KB Output is correct
4 Correct 92 ms 256 KB Output is correct
5 Correct 91 ms 504 KB Output is correct
6 Correct 96 ms 364 KB Output is correct
7 Correct 95 ms 376 KB Output is correct
8 Correct 96 ms 472 KB Output is correct
9 Correct 95 ms 256 KB Output is correct
10 Correct 96 ms 376 KB Output is correct
11 Correct 90 ms 256 KB Output is correct
12 Correct 93 ms 404 KB Output is correct
13 Correct 92 ms 256 KB Output is correct
14 Correct 92 ms 404 KB Output is correct
15 Correct 96 ms 376 KB Output is correct
16 Correct 93 ms 376 KB Output is correct
17 Correct 91 ms 504 KB Output is correct
18 Correct 92 ms 508 KB Output is correct
19 Correct 88 ms 380 KB Output is correct
20 Correct 82 ms 376 KB Output is correct
21 Correct 82 ms 376 KB Output is correct
22 Correct 96 ms 244 KB Output is correct
23 Correct 96 ms 376 KB Output is correct
24 Correct 94 ms 504 KB Output is correct
25 Correct 90 ms 256 KB Output is correct
26 Correct 93 ms 384 KB Output is correct
27 Correct 94 ms 400 KB Output is correct
28 Correct 93 ms 376 KB Output is correct
29 Correct 95 ms 376 KB Output is correct
30 Correct 88 ms 256 KB Output is correct
31 Correct 91 ms 404 KB Output is correct
32 Correct 92 ms 376 KB Output is correct
33 Correct 96 ms 376 KB Output is correct
34 Correct 95 ms 256 KB Output is correct
35 Correct 97 ms 376 KB Output is correct
36 Correct 95 ms 376 KB Output is correct
37 Correct 64 ms 376 KB Output is correct
38 Correct 63 ms 376 KB Output is correct
39 Correct 95 ms 504 KB Output is correct
40 Correct 93 ms 376 KB Output is correct
41 Correct 2 ms 380 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 256 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 99 ms 404 KB Output is correct
48 Correct 97 ms 504 KB Output is correct
49 Execution timed out 1072 ms 256 KB Time limit exceeded
50 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 91 ms 380 KB Output is correct
2 Correct 89 ms 376 KB Output is correct
3 Correct 92 ms 376 KB Output is correct
4 Correct 92 ms 256 KB Output is correct
5 Correct 91 ms 504 KB Output is correct
6 Correct 96 ms 364 KB Output is correct
7 Correct 95 ms 376 KB Output is correct
8 Correct 96 ms 472 KB Output is correct
9 Correct 95 ms 256 KB Output is correct
10 Correct 96 ms 376 KB Output is correct
11 Correct 90 ms 256 KB Output is correct
12 Correct 93 ms 404 KB Output is correct
13 Correct 92 ms 256 KB Output is correct
14 Correct 92 ms 404 KB Output is correct
15 Correct 96 ms 376 KB Output is correct
16 Correct 93 ms 376 KB Output is correct
17 Correct 91 ms 504 KB Output is correct
18 Correct 92 ms 508 KB Output is correct
19 Correct 88 ms 380 KB Output is correct
20 Correct 82 ms 376 KB Output is correct
21 Correct 82 ms 376 KB Output is correct
22 Correct 96 ms 244 KB Output is correct
23 Correct 96 ms 376 KB Output is correct
24 Correct 94 ms 504 KB Output is correct
25 Correct 90 ms 256 KB Output is correct
26 Correct 93 ms 384 KB Output is correct
27 Correct 94 ms 400 KB Output is correct
28 Correct 93 ms 376 KB Output is correct
29 Correct 95 ms 376 KB Output is correct
30 Correct 88 ms 256 KB Output is correct
31 Correct 91 ms 404 KB Output is correct
32 Correct 92 ms 376 KB Output is correct
33 Correct 96 ms 376 KB Output is correct
34 Correct 95 ms 256 KB Output is correct
35 Correct 97 ms 376 KB Output is correct
36 Correct 95 ms 376 KB Output is correct
37 Correct 64 ms 376 KB Output is correct
38 Correct 63 ms 376 KB Output is correct
39 Correct 95 ms 504 KB Output is correct
40 Correct 93 ms 376 KB Output is correct
41 Correct 2 ms 380 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 256 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 99 ms 404 KB Output is correct
48 Correct 97 ms 504 KB Output is correct
49 Execution timed out 1072 ms 256 KB Time limit exceeded
50 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 91 ms 380 KB Output is correct
2 Correct 89 ms 376 KB Output is correct
3 Correct 92 ms 376 KB Output is correct
4 Correct 92 ms 256 KB Output is correct
5 Correct 91 ms 504 KB Output is correct
6 Correct 96 ms 364 KB Output is correct
7 Correct 95 ms 376 KB Output is correct
8 Correct 96 ms 472 KB Output is correct
9 Correct 95 ms 256 KB Output is correct
10 Correct 96 ms 376 KB Output is correct
11 Correct 90 ms 256 KB Output is correct
12 Correct 93 ms 404 KB Output is correct
13 Correct 92 ms 256 KB Output is correct
14 Correct 92 ms 404 KB Output is correct
15 Correct 96 ms 376 KB Output is correct
16 Correct 93 ms 376 KB Output is correct
17 Correct 91 ms 504 KB Output is correct
18 Correct 92 ms 508 KB Output is correct
19 Correct 88 ms 380 KB Output is correct
20 Correct 82 ms 376 KB Output is correct
21 Correct 82 ms 376 KB Output is correct
22 Correct 96 ms 244 KB Output is correct
23 Correct 96 ms 376 KB Output is correct
24 Correct 94 ms 504 KB Output is correct
25 Correct 90 ms 256 KB Output is correct
26 Correct 93 ms 384 KB Output is correct
27 Correct 94 ms 400 KB Output is correct
28 Correct 93 ms 376 KB Output is correct
29 Correct 95 ms 376 KB Output is correct
30 Correct 88 ms 256 KB Output is correct
31 Correct 91 ms 404 KB Output is correct
32 Correct 92 ms 376 KB Output is correct
33 Correct 96 ms 376 KB Output is correct
34 Correct 95 ms 256 KB Output is correct
35 Correct 97 ms 376 KB Output is correct
36 Correct 95 ms 376 KB Output is correct
37 Correct 64 ms 376 KB Output is correct
38 Correct 63 ms 376 KB Output is correct
39 Correct 95 ms 504 KB Output is correct
40 Correct 93 ms 376 KB Output is correct
41 Correct 2 ms 380 KB Output is correct
42 Correct 2 ms 376 KB Output is correct
43 Correct 2 ms 256 KB Output is correct
44 Correct 2 ms 376 KB Output is correct
45 Correct 2 ms 376 KB Output is correct
46 Correct 2 ms 376 KB Output is correct
47 Correct 99 ms 404 KB Output is correct
48 Correct 97 ms 504 KB Output is correct
49 Execution timed out 1072 ms 256 KB Time limit exceeded
50 Halted 0 ms 0 KB -