Submission #1048513

# Submission time Handle Problem Language Result Execution time Memory
1048513 2024-08-08T08:02:39 Z lamagril Lightning Rod (NOI18_lightningrod) C++14
4 / 100
877 ms 178032 KB
#include <bits/stdc++.h>

using namespace std;

int main(){
    cin.tie(NULL)->sync_with_stdio(false);
    int n; cin >> n;
    stack<pair<int,int>> s;
    int a,b; cin >> a >> b;
    s.push({a,b});
    for(int ti=2 ; ti<=n ; ti++){
        int a,b; cin >> a >> b;
        bool bo=false;
        while(!s.empty() && a-s.top().first<=b-s.top().second){
            s.pop();
            b=true;
        }
        if(bo){
            s.push({a,b});
            continue;
        }
        if(abs(s.top().first-a)<=s.top().second-b){
            continue;
        }
        s.push({a,b});
    }
    cout << s.size() << '\n';
}
# Verdict Execution time Memory Grader output
1 Correct 877 ms 178032 KB Output is correct
2 Correct 844 ms 176632 KB Output is correct
3 Correct 802 ms 168404 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 877 ms 178032 KB Output is correct
2 Correct 844 ms 176632 KB Output is correct
3 Correct 802 ms 168404 KB Output is correct
4 Runtime error 1 ms 348 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -