Submission #110363

#TimeUsernameProblemLanguageResultExecution timeMemory
110363Leonardo_PaesCoin Collecting (JOI19_ho_t4)C++11
0 / 100
3 ms384 KiB
#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; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...