Submission #547192

# Submission time Handle Problem Language Result Execution time Memory
547192 2022-04-09T19:05:25 Z Ahmed57 Lightning Rod (NOI18_lightningrod) C++14
80 / 100
1850 ms 262148 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];
        if(i==0){
            per[0] = aa[0]+bb[0];
        }else{
            per[i] = max(per[i-1],aa[i]+bb[i]);
        }
    }
    suf[n-1] = bb[n-1]-aa[n-1];
    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 1385 ms 152012 KB Output is correct
2 Correct 1399 ms 151588 KB Output is correct
3 Correct 1320 ms 147512 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 1 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 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
# 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 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 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 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 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 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 35 ms 3156 KB Output is correct
15 Correct 38 ms 3336 KB Output is correct
16 Correct 37 ms 3168 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1409 ms 156232 KB Output is correct
2 Correct 1389 ms 156116 KB Output is correct
3 Correct 1372 ms 152272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1385 ms 152012 KB Output is correct
2 Correct 1399 ms 151588 KB Output is correct
3 Correct 1320 ms 147512 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 1 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 35 ms 3156 KB Output is correct
18 Correct 38 ms 3336 KB Output is correct
19 Correct 37 ms 3168 KB Output is correct
20 Correct 1409 ms 156232 KB Output is correct
21 Correct 1389 ms 156116 KB Output is correct
22 Correct 1372 ms 152272 KB Output is correct
23 Correct 1679 ms 142132 KB Output is correct
24 Runtime error 1850 ms 262148 KB Memory limit exceeded
25 Halted 0 ms 0 KB -