Submission #547186

# Submission time Handle Problem Language Result Execution time Memory
547186 2022-04-09T18:53:01 Z Ahmed57 Lightning Rod (NOI18_lightningrod) C++14
66 / 100
2000 ms 132284 KB
#include<bits/stdc++.h>
using namespace std;


int main() {
    long long n;cin>>n;
    vector<pair<long long,long long>> v;
    for(int i = 0;i<n;i++){
        long long a,b;
        cin>>a>>b;
        v.push_back({a,b});
    }
    long long per[n]={} , suf[n]={};
    per[0] = v[0].first+v[0].second;
    suf[n-1] = v[n-1].second-v[n-1].first;
    for(int i = 1;i<n;i++){
        per[i] = max(per[i-1],v[i].first+v[i].second);
    }for(int i = n-2;i>=0;i--){
        suf[i] = max(suf[i+1],v[i].second-v[i].first);
    }
    long long ans = 0;
    for(int i = 0;i<n;i++){
        if(i==0){
            if(suf[i+1]<v[i].second-v[i].first){
                ans++;
            }
        }else if(i==n-1){
            if(per[i-1]<v[i].first+v[i].second)ans++;
        }else{
            if(suf[i+1]<v[i].second-v[i].first&&per[i-1]<v[i].first+v[i].second)ans++;
        }
    }
    cout<<ans<<"\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Execution timed out 2089 ms 66784 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 178 ms 6164 KB Output is correct
15 Correct 135 ms 6464 KB Output is correct
16 Correct 126 ms 6260 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 2035 ms 132284 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2089 ms 66784 KB Time limit exceeded
2 Halted 0 ms 0 KB -