Submission #209544

#TimeUsernameProblemLanguageResultExecution timeMemory
209544Alexa2001Lightning Rod (NOI18_lightningrod)C++17
100 / 100
794 ms224076 KiB
#include <bits/stdc++.h> using namespace std; const int Nmax = 1e7 + 5; int x[Nmax], y[Nmax], n; bitset<Nmax> good; const int bsize = 1<<18; char buffer[bsize+2]; int cursor; static inline void init_read() { fread(buffer, 1, bsize, stdin), cursor = 0; } void read(int &x) { x = 0; while(!isdigit(buffer[cursor])) { ++cursor; if(cursor == bsize) init_read(); } while(isdigit(buffer[cursor])) { x = x * 10 + buffer[cursor] - '0'; ++cursor; if(cursor == bsize) init_read(); } } int main() { // freopen("input", "r", stdin); init_read(); int i; int ans = 0; read(n); for(i=1; i<=n; ++i) read(x[i]), read(y[i]); int mx = INT_MIN; for(i=1; i<=n; ++i) if(x[i] + y[i] > mx) good[i] = 1, mx = x[i] + y[i]; mx = INT_MIN; for(i=n; i; --i) if(y[i] - x[i] > mx) mx = y[i] - x[i], ans += good[i]; cout << ans << '\n'; return 0; }

Compilation message (stderr)

lightningrod.cpp: In function 'void init_read()':
lightningrod.cpp:16:35: warning: ignoring return value of 'size_t fread(void*, size_t, size_t, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     fread(buffer, 1, bsize, stdin), cursor = 0;
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
#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...