Submission #544637

# Submission time Handle Problem Language Result Execution time Memory
544637 2022-04-02T14:09:51 Z AbdelmagedNour Lightning Rod (NOI18_lightningrod) C++17
40 / 100
1701 ms 262144 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int N=10000005;
int n,x[N],y[N],a[N],b[N],nxta[N],nxtb[N];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
        a[i]=y[i]-x[i];
        b[i]=y[i]+x[i];
    }
    vector<int>st;
    for(int i=n-1;i>=0;i--){
        while(!st.empty()&&a[st.back()]<a[i])st.pop_back();
        nxta[i]=(st.empty()?-1:st.back());
        st.push_back(i);
    }
    st.clear();
    for(int i=n-1;i>=0;i--){
        while(!st.empty()&&b[st.back()]<b[i])st.pop_back();
        nxtb[i]=(st.empty()?n:st.back());
        st.push_back(i);
    }
    int res=0,pos=0;
    while(pos<n){
        res++;
        while(nxta[pos]!=-1)pos=nxta[pos];
        pos=nxtb[pos];
    }
    cout<<res;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1701 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 324 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 2 ms 340 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 44 ms 5336 KB Output is correct
15 Correct 48 ms 5556 KB Output is correct
16 Incorrect 55 ms 5836 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1635 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1701 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -