Submission #828917

#TimeUsernameProblemLanguageResultExecution timeMemory
828917NK_Lightning Rod (NOI18_lightningrod)C++17
100 / 100
1545 ms157096 KiB
// Success consists of going from failure to failure without loss of enthusiasm #include <bits/stdc++.h> using namespace std; #define nl '\n' #define pb push_back #define mp make_pair #define f first #define s second #define sz(x) int(x.size()) template<class T> using V = vector<T>; using vi = V<int>; using ll = long long; using pi = pair<int, int>; using vpi = V<pi>; using vl = V<ll>; using db = double; const int INF = 1e9 + 10; int main() { cin.tie(0)->sync_with_stdio(0); int N; scanf("%d", &N); vpi stk; for(int i = 0; i < N; i++) { int x, y; scanf("%d %d", &x, &y); int l = x - y, r = x + y; while(sz(stk) && l <= stk.back().f && stk.back().s <= r) stk.pop_back(); if (!sz(stk) || stk.back().s < r) stk.pb(mp(l, r)); } cout << sz(stk) << nl; exit(0-0); }

Compilation message (stderr)

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:26:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |  int N; scanf("%d", &N);
      |         ~~~~~^~~~~~~~~~
lightningrod.cpp:30:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   int x, y; scanf("%d %d", &x, &y);
      |             ~~~~~^~~~~~~~~~~~~~~~~
#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...