Submission #220743

# Submission time Handle Problem Language Result Execution time Memory
220743 2020-04-08T14:10:31 Z DmitryGrigorev Coin Collecting (JOI19_ho_t4) C++14
0 / 100
11 ms 384 KB
#include <bits/stdc++.h>
#define int long long
#define db long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

using namespace std;

int sum[100007][3];

main(){
#ifdef LOCAL
	freopen("N_input.txt", "r", stdin);
	//freopen("N_output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	int ans = 0;

	for (int i = 0; i < 2*n; ++i) {
		int x, y;
		cin >> x >> y;

		int z, t;
		if (x <= 0) z = 1;
		else if (x > n) z = n;
		else z = x;

		if (y <= 1) t = 1;
		else t = 2;

		ans += abs(x-z) + abs(y-t);

		sum[z][t]++;
	}

	int bal = 0;

	for (int i = 0; i <= n; ++i) {
		for (int y = 0; y < 2; ++y) {
			int x = i-y;
			if (x < 0 || x >= n) continue;
			bal += sum[x+1][y+1] - 1;
		}
		ans += abs(bal);
	}

	cout << ans;

}

Compilation message

joi2019_ho_t4.cpp:14:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
# Verdict Execution time Memory Grader output
1 Correct 11 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Incorrect 4 ms 384 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Incorrect 4 ms 384 KB Output isn't correct
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 11 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Incorrect 4 ms 384 KB Output isn't correct
8 Halted 0 ms 0 KB -