답안 #110363

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
110363 2019-05-10T18:11:44 Z Leonardo_Paes Coin Collecting (JOI19_ho_t4) C++11
0 / 100
3 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

typedef pair<long long, long long> pii;

int main(){

    int n;

    cin >> n;

    priority_queue<pii> fila;

    long long ans=0;

    for(int i=1; i<=2*n; i++){
        pii atual;

        cin >> atual.first >> atual.second;

        fila.push(atual);
    }

    for(int i=n; i>=1; i--){
            pii atual1 = fila.top();
            fila.pop();
            pii atual2 = fila.top();
            fila.pop();
            long long dist1 = abs(atual1.first-i) + abs(atual1.second-1);
            dist1 += abs(atual2.first-i) + abs(atual2.second-2);
            long long dist2 = abs(atual2.first-i) + abs(atual2.second-1);
            dist2 += abs(atual1.first-i) + abs(atual1.second-2);
            ans+=min(dist1, dist2);
    }

    cout << ans << endl;

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