Submission #544652

#TimeUsernameProblemLanguageResultExecution timeMemory
544652pokmui9909화살표 그리기 (KOI18_arrowH)C++17
33 / 100
2 ms628 KiB
#include <string> #include <iostream> #include <algorithm> #include <queue> #include <stack> #include <vector> #include <deque> #include <functional> #include <climits> using namespace std; int main() { cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false); int n; cin >> n; pair<int, int> ar[5005]; for (int i = 0; i < n; i++) cin >> ar[i].first >> ar[i].second; sort(ar, ar + n); int ans = 0; for (int i = 0; i < n; i++) { int k = INT_MAX; for (int j = i - 1; j >= 0; j--) { if (ar[j].second == ar[i].second) { k = min(k, ar[i].first - ar[j].first); break; } } for (int j = i + 1; j < n; j++) { if (ar[j].second == ar[i].second) { k = min(k, ar[j].first - ar[i].first); break; } } ans += k; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...