Submission #954687

# Submission time Handle Problem Language Result Execution time Memory
954687 2024-03-28T10:53:15 Z Warinchai Lightning Rod (NOI18_lightningrod) C++14
100 / 100
1422 ms 262144 KB
#include<bits/stdc++.h>
using namespace std;
vector<pair<int,int>>v;
bool check(pair<int,int>f,pair<int,int>s){
    return abs(f.first-s.first)<=f.second-s.second;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;cin>>n;
    int a,b;
    for(int i=1;i<=n;i++){
        cin>>a>>b;
        v.push_back({a,b});
    }
    stack<pair<int,int>>st;
    st.push(v[0]);
    for(int i=1;i<n;i++){
        a=v[i].first;
        b=v[i].second;
        if(!check(st.top(),v[i])){
            while(!st.empty()&&check(v[i],st.top())){
                st.pop();
            }
            st.push(v[i]);
        }
    }
    cout<<st.size();
}
# Verdict Execution time Memory Grader output
1 Correct 1200 ms 243092 KB Output is correct
2 Correct 1223 ms 242980 KB Output is correct
3 Correct 1183 ms 247788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 388 KB Output is correct
12 Correct 1 ms 592 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 388 KB Output is correct
12 Correct 1 ms 592 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 30 ms 5580 KB Output is correct
15 Correct 30 ms 5320 KB Output is correct
16 Correct 28 ms 5320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1225 ms 202796 KB Output is correct
2 Correct 1181 ms 205472 KB Output is correct
3 Correct 1161 ms 203380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1200 ms 243092 KB Output is correct
2 Correct 1223 ms 242980 KB Output is correct
3 Correct 1183 ms 247788 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 388 KB Output is correct
15 Correct 1 ms 592 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 30 ms 5580 KB Output is correct
18 Correct 30 ms 5320 KB Output is correct
19 Correct 28 ms 5320 KB Output is correct
20 Correct 1225 ms 202796 KB Output is correct
21 Correct 1181 ms 205472 KB Output is correct
22 Correct 1161 ms 203380 KB Output is correct
23 Correct 1422 ms 262144 KB Output is correct
24 Correct 1323 ms 242648 KB Output is correct
25 Correct 1309 ms 228876 KB Output is correct