답안 #425469

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
425469 2021-06-13T04:11:51 Z Namnamseo Coin Collecting (JOI19_ho_t4) C++17
0 / 100
1 ms 204 KB
#include <iostream>
#include <algorithm>
using namespace std;
using ll=long long;
using pp=pair<int, int>;
#define rep(i, n) for (int i=0; i<n; ++i)
#define rrep(i, n) for (int i=1; i<=n; ++i)

const int maxn = int(1e5) + 10;

int n;
ll ans;
int c[3][maxn];

int main()
{
	cin.tie(0)->sync_with_stdio(0);

	cin >> n;
	rrep(i, 2*n) {
		int x, y; cin >> x >> y;
		auto Bound = [&](int &v, int l, int r) {
			if (v < l) { ans += l-v; v = l; }
			else if (v > r) { ans += v-r; v = r; }
		};
		Bound(x, 1, n);
		Bound(y, 1, 2);
		++c[y][x];
	}

	for (int i=1, cl=0; i<n; ++i) {
		rrep(j, 2) cl+=c[j][i];
		int need = i*2;
		ans += abs(need-cl);
	}
	int uc = 0;
	for (int i=1; i<=n; ++i) uc += c[1][i];
	ans += abs(n-uc);

	cout << ans << '\n';

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Incorrect 1 ms 204 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Incorrect 1 ms 204 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Incorrect 1 ms 204 KB Output isn't correct
7 Halted 0 ms 0 KB -