Submission #313304

#TimeUsernameProblemLanguageResultExecution timeMemory
313304kaplanbarLightning Rod (NOI18_lightningrod)C++11
66 / 100
2093 ms75728 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr int N = 1e7+1; int n; bool v[N]; pair<int,int> a[N]; int main() { //ios_base::sync_with_stdio(false); //cin.tie(0); cin >> n; for(int i = 0; i < n; i++) { scanf("%d %d", &a[i].first, &a[i].second); //cin >> a[i].first >> a[i].second; } int mx = -2000000000; for(int i = 0; i < n; i++) { int val = a[i].first + a[i].second; if(mx >= val) { v[i] = 1; } else { mx = val; } } mx = -2000000000; for(int i = n - 1; i >= 0; i--) { int val = a[i].second - a[i].first; if(mx >= val) { v[i] = 1; } else { mx = val; } } int ans = 0; for(int i = 0; i < n; i++) ans += v[i]; //cout << n-ans; printf("%d",n-ans); return 0; }

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:13:12: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   13 |       scanf("%d %d", &a[i].first, &a[i].second);
      |       ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...