Submission #679658

# Submission time Handle Problem Language Result Execution time Memory
679658 2023-01-08T20:25:20 Z ethening Coin Collecting (JOI19_ho_t4) C++17
0 / 100
1 ms 212 KB
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	vector cnt(3, vector(n + 5, 0));
	ll ans = 0;
	for (int i = 1; i <= 2 * n; i++) {
		ll x, y;
		cin >> x >> y;
		ll tarx, tary;
		if (x >= 1 && x <= n) {
			tarx = x;
		}
		else {
			if (x < 1) tarx = 1;
			else tarx = n;
		}
		if (y >= 1 && y <= 2) {
			tary = y;
		}
		else {
			if (y < 1) tary = 1;
			else tary = 2;
		}
		++cnt[tary][tarx];
		ans += abs(x - tarx) + abs(y - tary);
	}
	
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		sum += cnt[1][i] + cnt[2][i];
		int req = 2 * i;
		ans += abs(req - sum); 
	}

	int sum2 = 0;
	for (int i = 1; i <= n; i++) {
		sum2 += cnt[1][i];
	}
	ans += abs(n - sum2);

	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Incorrect 1 ms 212 KB Output isn't correct
7 Halted 0 ms 0 KB -