Submission #384489

# Submission time Handle Problem Language Result Execution time Memory
384489 2021-04-01T18:03:46 Z valerikk Coin Collecting (JOI19_ho_t4) C++17
0 / 100
2 ms 364 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;

#define x first
#define y second
#define all(a) (a).begin(), (a).end()

const int N = 1e5 + 7;

int a[N][2];

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif 
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 0; i < 2 * n; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        if (x < 0) {
            ans += -x;
            x = 0;
        }
        if (x > n - 1) {
            ans += x - n + 1;
            x = n - 1;
        }
        if (y < 0) {
            ans += -y;
            y = 0;
        }
        if (y > 1) {
            ans += y - 1;
            y = 1;
        }
        a[x][y]++;
    }
    int s = 0, s1 = 0;
    for (int i = 0; i < n; i++) {
        s += a[i][0];
        s1 += a[i][1];
        ans += abs(2 * (i + 1) - s - s1);
    }
    ans += abs(s - s1) / 2;
    cout << ans << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Incorrect 1 ms 364 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Incorrect 1 ms 364 KB Output isn't correct
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 2 ms 364 KB Output is correct
5 Correct 2 ms 364 KB Output is correct
6 Incorrect 1 ms 364 KB Output isn't correct
7 Halted 0 ms 0 KB -