Submission #1302733

#TimeUsernameProblemLanguageResultExecution timeMemory
1302733ducdev화살표 그리기 (KOI18_arrowH)C++17
100 / 100
33 ms25224 KiB
// Author: 4uckd3v - Nguyen Cao Duc #include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAX_N = 1e6; const int MOD = 1e9 + 7; vector<int> pos[MAX_N + 5]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); if (fopen("ARROW.INP", "r")) { freopen("ARROW.INP", "r", stdin); freopen("ARROW.OUT", "w", stdout); }; int n; cin >> n; for (int i = 1; i <= n; i++) { int x, color; cin >> x >> color; pos[color].push_back(x); }; ll res = 0; for (int i = 1; i <= MAX_N; i++) { sort(pos[i].begin(), pos[i].end()); for (int j = 0; j < pos[i].size(); j++) { int minDist = 2e9; if (j > 0) minDist = min(minDist, pos[i][j] - pos[i][j - 1]); if (j + 1 < pos[i].size()) minDist = min(minDist, pos[i][j + 1] - pos[i][j]); if (minDist < 2e9) res += minDist; }; }; cout << res; };

Compilation message (stderr)

arrow.cpp: In function 'int main()':
arrow.cpp:16:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |         freopen("ARROW.INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
arrow.cpp:17:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |         freopen("ARROW.OUT", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...