Submission #170689

#TimeUsernameProblemLanguageResultExecution timeMemory
170689isvara화살표 그리기 (KOI18_arrowH)C++14
100 / 100
45 ms6008 KiB
#include<iostream> #include<algorithm> #include<queue> #include<set> #include<map> #include<vector> #include<string.h> #include<math.h> #include<stack> #include<assert.h> using namespace std; typedef long long ll; const int max_n =1e5+1; int N; vector<ll>points[max_n]; ll ans; int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> N; for (int i = 0; i < N; i++) { ll coor, color; cin >> coor >> color; points[color].push_back(coor); } for (int i = 1; i <= N; i++) sort(points[i].begin(), points[i].end()); for (int i = 1; i <= N; i++) { if (points[i].size() == 1 || points[i].size()==0) continue; for (int j = 1; j < points[i].size()-1; j++) { ll l = points[i][j - 1]; ll r = points[i][j + 1]; ans += min(r - points[i][j], points[i][j] - l); } int e = points[i].size() - 1; ans += points[i][1] - points[i][0]; ans += points[i][e] - points[i][e - 1]; } cout << ans; }

Compilation message (stderr)

arrow.cpp: In function 'int main()':
arrow.cpp:41:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 1; j < points[i].size()-1; j++)
                   ~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...