Submission #1196800

#TimeUsernameProblemLanguageResultExecution timeMemory
1196800loomLightning Rod (NOI18_lightningrod)C++20
100 / 100
472 ms117368 KiB
#include <bits/stdc++.h> using namespace std; inline int readInt() { int x = 0; char ch = getchar(); while (ch < '0' || ch > '9') ch = getchar_unlocked(); while (ch >= '0' && ch <= '9'){ x = (x << 3) + (x << 1) + ch - '0'; ch = getchar_unlocked(); } return x; } int main(){ int n = readInt(); vector<pair<int,int>> a(n); for(int i = 0; i < n; i++) { a[i].first = readInt(); a[i].second = readInt(); if(i > 0 and a[i].first == a[i-1].first) cout<<"haha"; } int ans = n; int mx = -1; vector<int> tf(n, 0); for(int i=0; i<n; i++){ auto [x, y] = a[i]; if(x+y <= mx) ans--, tf[i] = 1; else mx = x+y; } int mn = 1e18; for(int i=n-1; i>=0; i--){ if(tf[i]) continue; auto [x, y] = a[i]; if(x-y >= mn) ans--; else mn = x-y; } cout<<ans; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:34:14: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
   34 |     int mn = 1e18;
      |              ^~~~
#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...