Submission #547191

# Submission time Handle Problem Language Result Execution time Memory
547191 2022-04-09T19:02:39 Z Ahmed57 Lightning Rod (NOI18_lightningrod) C++14
80 / 100
2000 ms 255632 KB
#include<bits/stdc++.h>
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    int per[n] , suf[n];
    int aa[n], bb[n];
    for(int i = 0;i<n;i++){
        cin>>aa[i]>>bb[i];
    }
    per[0] = aa[0]+bb[0];
    suf[n-1] = bb[n-1]-aa[n-1];
    for(int i = 1;i<n;i++){
        per[i] = max(per[i-1],aa[i]+bb[i]);
    }for(int i = n-2;i>=0;i--){
        suf[i] = max(suf[i+1],bb[i]-aa[i]);
    }
    int ans = 0;
    for(int i = 0;i<n;i++){
        if(i==0){
            if(suf[i+1]<bb[i]-aa[i]){
                ans++;
            }
        }else if(i==n-1){
            if(per[i-1]<aa[i]+bb[i])ans++;
        }else{
            if(suf[i+1]<bb[i]-aa[i]&&per[i-1]<aa[i]+bb[i])ans++;
        }
    }
    cout<<ans<<"\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1533 ms 198120 KB Output is correct
2 Correct 1573 ms 227484 KB Output is correct
3 Correct 1565 ms 218036 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 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 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 50 ms 3200 KB Output is correct
15 Correct 44 ms 3336 KB Output is correct
16 Correct 42 ms 3168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1598 ms 199468 KB Output is correct
2 Correct 1596 ms 235544 KB Output is correct
3 Correct 1580 ms 227884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1533 ms 198120 KB Output is correct
2 Correct 1573 ms 227484 KB Output is correct
3 Correct 1565 ms 218036 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 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 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 50 ms 3200 KB Output is correct
18 Correct 44 ms 3336 KB Output is correct
19 Correct 42 ms 3168 KB Output is correct
20 Correct 1598 ms 199468 KB Output is correct
21 Correct 1596 ms 235544 KB Output is correct
22 Correct 1580 ms 227884 KB Output is correct
23 Execution timed out 2076 ms 255632 KB Time limit exceeded
24 Halted 0 ms 0 KB -