Submission #220743

#TimeUsernameProblemLanguageResultExecution timeMemory
220743DmitryGrigorevCoin Collecting (JOI19_ho_t4)C++14
0 / 100
11 ms384 KiB
#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 (stderr)

joi2019_ho_t4.cpp:14:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...