Submission #167590

#TimeUsernameProblemLanguageResultExecution timeMemory
167590cgiosy화살표 그리기 (KOI18_arrowH)C++17
100 / 100
149 ms5492 KiB
#include <bits/stdc++.h> #define rep(i,x,n) for(int i=x; i<n; i++) using namespace std; int main() { int N; cin>>N; vector<vector<int>> A(N); rep(i, 0, N) { int x, y; cin>>x>>y; --y; A[y].push_back(x); } long long s=0; for(auto&v:A) { int M=v.size(); sort(begin(v), end(v)); if(M>=2) { s+=v[1]-v[0]+v[M-1]-v[M-2]; rep(i, 1, M-1) s+=min(v[i]-v[i-1], v[i+1]-v[i]); } } cout<<s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...