답안 #884371

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
884371 2023-12-07T08:57:19 Z RaresFelix Coin Collecting (JOI19_ho_t4) C++17
0 / 100
0 ms 348 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(vll &V, ll st, ll dr, ll 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));
    ll p = 0;

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

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll n;
    vll X, Y;
    cin >> n;
    for(ll i = 0; i < 2 * n; ++i) {
        ll 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 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 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 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 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 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -