# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
824328 | christinelynn | Lightning Rod (NOI18_lightningrod) | C++17 | 659 ms | 246460 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 INF=1e18;
int n, ans;
void read(int &in) {
in=0;
for(char c=getchar(); '0'<=c && c<='9'; c=getchar()) in=10*in+c-'0';
}
void post(int out) {
char dig[11];
int idx=0;
do{
dig[idx++]='0'+out%10;
out/=10;
} while(out);
idx--;
while(idx>=0) putchar(dig[idx--]);
}
int main() {
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, x, y, ans=0; read(n);
pair<int, int> a[n];
int temp=-INF;
for(int i=0; i<n; i++) {
read(x); read(y);
a[i].second=x-y;
if(x+y<=temp) a[i].first=0;
else a[i].first=1;
temp=max(temp, x+y);
} temp=INF;
for(int i=n-1; i>=0; i--) {
if(a[i].second<temp) ans+=a[i].first;
temp=min(temp, a[i].second);
}
post(ans); putchar('\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... |