답안 #106344

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
106344 2019-04-18T00:44:02 Z tincamatei Coin Collecting (JOI19_ho_t4) C++14
8 / 100
324 ms 504 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 20;
pair<int, int> points[MAX_N];

int main() {
#ifdef HOME
	FILE *fin = fopen("coin.in", "r");
	FILE *fout = fopen("coin.out", "w");
#else
	FILE *fin = stdin;
	FILE *fout = stdout;
#endif

	int n;
	fscanf(fin, "%d", &n);
	for(int i = 0; i < 2 * n; ++i)
		fscanf(fin, "%d%d", &points[i].first, &points[i].second);
	
	sort(points, points + 2 * n);
	
	long long best = 1LL << 60;

	for(int mask = 0; mask < (1 << (2 * n)); ++mask) {
		long long rez = 0LL;
		int lp = 0, up = 0;

		for(int i = 0; i < 2 * n; ++i)
			if((1 << i) & mask) {
				++lp;
				rez = rez + llabs(points[i].first - lp) + llabs(points[i].second - 1);
			} else {
				++up;
				rez = rez + llabs(points[i].first - up) + llabs(points[i].second - 2);
			}

		if(lp == n && up == n)
			best = min(best, rez);
	}

	fprintf(fout, "%lld", best);

	fclose(fin);
	fclose(fout);
	return 0;
}

Compilation message

joi2019_ho_t4.cpp: In function 'int main()':
joi2019_ho_t4.cpp:18:8: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  fscanf(fin, "%d", &n);
  ~~~~~~^~~~~~~~~~~~~~~
joi2019_ho_t4.cpp:20:9: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   fscanf(fin, "%d%d", &points[i].first, &points[i].second);
   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 84 ms 384 KB Output is correct
5 Correct 83 ms 256 KB Output is correct
6 Correct 116 ms 384 KB Output is correct
7 Correct 104 ms 504 KB Output is correct
8 Correct 104 ms 384 KB Output is correct
9 Correct 88 ms 356 KB Output is correct
10 Correct 94 ms 504 KB Output is correct
11 Correct 86 ms 396 KB Output is correct
12 Correct 93 ms 504 KB Output is correct
13 Correct 91 ms 412 KB Output is correct
14 Correct 98 ms 384 KB Output is correct
15 Correct 111 ms 384 KB Output is correct
16 Correct 89 ms 384 KB Output is correct
17 Correct 124 ms 356 KB Output is correct
18 Correct 100 ms 376 KB Output is correct
19 Correct 93 ms 384 KB Output is correct
20 Correct 115 ms 356 KB Output is correct
21 Correct 95 ms 352 KB Output is correct
22 Correct 105 ms 356 KB Output is correct
23 Correct 99 ms 384 KB Output is correct
24 Correct 96 ms 376 KB Output is correct
25 Correct 95 ms 460 KB Output is correct
26 Correct 93 ms 356 KB Output is correct
27 Correct 91 ms 356 KB Output is correct
28 Correct 90 ms 256 KB Output is correct
29 Correct 114 ms 384 KB Output is correct
30 Correct 94 ms 384 KB Output is correct
31 Correct 93 ms 420 KB Output is correct
32 Correct 94 ms 384 KB Output is correct
33 Correct 83 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 84 ms 384 KB Output is correct
5 Correct 83 ms 256 KB Output is correct
6 Correct 116 ms 384 KB Output is correct
7 Correct 104 ms 504 KB Output is correct
8 Correct 104 ms 384 KB Output is correct
9 Correct 88 ms 356 KB Output is correct
10 Correct 94 ms 504 KB Output is correct
11 Correct 86 ms 396 KB Output is correct
12 Correct 93 ms 504 KB Output is correct
13 Correct 91 ms 412 KB Output is correct
14 Correct 98 ms 384 KB Output is correct
15 Correct 111 ms 384 KB Output is correct
16 Correct 89 ms 384 KB Output is correct
17 Correct 124 ms 356 KB Output is correct
18 Correct 100 ms 376 KB Output is correct
19 Correct 93 ms 384 KB Output is correct
20 Correct 115 ms 356 KB Output is correct
21 Correct 95 ms 352 KB Output is correct
22 Correct 105 ms 356 KB Output is correct
23 Correct 99 ms 384 KB Output is correct
24 Correct 96 ms 376 KB Output is correct
25 Correct 95 ms 460 KB Output is correct
26 Correct 93 ms 356 KB Output is correct
27 Correct 91 ms 356 KB Output is correct
28 Correct 90 ms 256 KB Output is correct
29 Correct 114 ms 384 KB Output is correct
30 Correct 94 ms 384 KB Output is correct
31 Correct 93 ms 420 KB Output is correct
32 Correct 94 ms 384 KB Output is correct
33 Correct 83 ms 384 KB Output is correct
34 Execution timed out 324 ms 384 KB Time limit exceeded (wall clock)
35 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 84 ms 384 KB Output is correct
5 Correct 83 ms 256 KB Output is correct
6 Correct 116 ms 384 KB Output is correct
7 Correct 104 ms 504 KB Output is correct
8 Correct 104 ms 384 KB Output is correct
9 Correct 88 ms 356 KB Output is correct
10 Correct 94 ms 504 KB Output is correct
11 Correct 86 ms 396 KB Output is correct
12 Correct 93 ms 504 KB Output is correct
13 Correct 91 ms 412 KB Output is correct
14 Correct 98 ms 384 KB Output is correct
15 Correct 111 ms 384 KB Output is correct
16 Correct 89 ms 384 KB Output is correct
17 Correct 124 ms 356 KB Output is correct
18 Correct 100 ms 376 KB Output is correct
19 Correct 93 ms 384 KB Output is correct
20 Correct 115 ms 356 KB Output is correct
21 Correct 95 ms 352 KB Output is correct
22 Correct 105 ms 356 KB Output is correct
23 Correct 99 ms 384 KB Output is correct
24 Correct 96 ms 376 KB Output is correct
25 Correct 95 ms 460 KB Output is correct
26 Correct 93 ms 356 KB Output is correct
27 Correct 91 ms 356 KB Output is correct
28 Correct 90 ms 256 KB Output is correct
29 Correct 114 ms 384 KB Output is correct
30 Correct 94 ms 384 KB Output is correct
31 Correct 93 ms 420 KB Output is correct
32 Correct 94 ms 384 KB Output is correct
33 Correct 83 ms 384 KB Output is correct
34 Execution timed out 324 ms 384 KB Time limit exceeded (wall clock)
35 Halted 0 ms 0 KB -