Submission #345041

#TimeUsernameProblemLanguageResultExecution timeMemory
345041nishuzLightning Rod (NOI18_lightningrod)C++14
40 / 100
2094 ms88044 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, ans = 0, subtask = 1; cin >> n; vector <pair <int, int>> a(n); bool vis[n], ok = 1; memset(vis, 0, sizeof vis); for (int i = 0; i < n; ++i) { cin >> a[i].first >> a[i].second; ok &= (a[i].second == 0); if (i) subtask += (a[i].first != a[i-1].first); } if (ok) { cout << subtask << '\n'; return 0; } sort(a.begin(), a.end(), [&](pair <int, int>& a, pair <int, int>& b) {return a.second > b.second;}); for (int i = 0; i < n; ++i) { if (vis[i]) continue; ++ans; for (int j = 0; j < n; ++j) if (abs(a[i].first - a[j].first) <= abs(a[i].second - a[j].second)) vis[j] = 1; } cout << ans << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...