# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
209544 | Alexa2001 | Lightning Rod (NOI18_lightningrod) | C++17 | 794 ms | 224076 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |