Submission #1111337

# Submission time Handle Problem Language Result Execution time Memory
1111337 2024-11-12T06:33:09 Z fyan Coin Collecting (JOI19_ho_t4) C++14
0 / 100
2 ms 4432 KB
#include "bits/stdc++.h"
using namespace std;
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()
#define int long long
const int mxn = 2e5+5;

int N,X[mxn],Y[mxn];
int A[mxn];

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	
	cin>>N;
	int res = 0;
	for (int i=0; i<2*N; i++) {
		cin>>X[i]>>Y[i];
		if (X[i] < 1) {
			res += 1-X[i];
			X[i] = 1;
		}
		if (X[i] > N) {
			res += X[i]-N;
			X[i] = N;
		}
		if (Y[i] < 1) {
			res += 1-Y[i];
			Y[i] = 1;
		}
		if (Y[i] > 2) {
			res += Y[i]-2;
			Y[i] = 2;
		}
	}
	int c1 = 0, c2 = 0;
	for (int i=0; i<2*N; i++) {
		if (Y[i] == 1) c1++;
		else c2++;
	}
	res += max(c1,c2)-N;
	for (int i=0; i<2*N; i++) {
		A[X[i]]++;
	}
	for (int i=1; i<=N; i++) {
		A[i] += A[i-1];
		res += abs(A[i]-2*i);
	}
	cout<<res;
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4432 KB Output is correct
2 Correct 1 ms 4432 KB Output is correct
3 Correct 2 ms 4432 KB Output is correct
4 Correct 1 ms 4432 KB Output is correct
5 Correct 1 ms 4432 KB Output is correct
6 Incorrect 1 ms 4432 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4432 KB Output is correct
2 Correct 1 ms 4432 KB Output is correct
3 Correct 2 ms 4432 KB Output is correct
4 Correct 1 ms 4432 KB Output is correct
5 Correct 1 ms 4432 KB Output is correct
6 Incorrect 1 ms 4432 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4432 KB Output is correct
2 Correct 1 ms 4432 KB Output is correct
3 Correct 2 ms 4432 KB Output is correct
4 Correct 1 ms 4432 KB Output is correct
5 Correct 1 ms 4432 KB Output is correct
6 Incorrect 1 ms 4432 KB Output isn't correct
7 Halted 0 ms 0 KB -