답안 #884365

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
884365 2023-12-07T08:51:11 Z RaresFelix Coin Collecting (JOI19_ho_t4) C++17
0 / 100
1 ms 464 KB
#include <bits/stdc++.h>
//#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using db = long double;  // or double, if TL is tight
using str = string; 
using ii = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;

ll solve(vi &V, int st, int dr, int delta) {
    ll re = 0;
    for(auto &it : V) {
        if(it < st) {
            re += st - it;
            it = st;
        }
        if(it > dr) {
            re += it - dr;
            it = dr;
        }
    }
    sort(all(V));
    int p = 0;

    for(int i = st; i < dr; ++i) {
        ///bara dintre i si i + 1
        while(p < sz(V) && V[p] <= i) ++p;
        re += abs(p - delta * (i - st + 1));
    }

    return re;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    vi X, Y;
    cin >> n;
    for(int i = 0; i < 2 * n; ++i) {
        int x, y;
        cin >> x >> y;
        X.push_back(x);
        Y.push_back(y);
    }
    ll re = solve(X, 1, n, 2) + solve(Y, 1, 2, n);
    cout << re << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 464 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 464 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 464 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -