Submission #345040

#TimeUsernameProblemLanguageResultExecution timeMemory
345040nishuzLightning Rod (NOI18_lightningrod)C++14
40 / 100
2093 ms262148 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; cin >> n; vector <pair <int, int>> a(n); unordered_map <int, int> um; 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); ++um[a[i].first]; } if (ok) { cout << um.size() << '\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...