답안 #544628

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
544628 2022-04-02T14:03:15 Z AbdelmagedNour Lightning Rod (NOI18_lightningrod) C++17
40 / 100
1681 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];
    }
    stack<int>st;
    for(int i=n-1;i>=0;i--){
        while(!st.empty()&&a[st.top()]<a[i])st.pop();
        nxta[i]=(st.empty()?-1:st.top());
        st.push(i);
    }
    st=stack<int>();
    for(int i=n-1;i>=0;i--){
        while(!st.empty()&&b[st.top()]<b[i])st.pop();
        nxtb[i]=(st.empty()?n:st.top());
        st.push(i);
    }
    int res=0;
    int pos=0;
    while(pos<n){
        res++;
        while(nxta[pos]!=-1)pos=nxta[pos];
        pos=nxtb[pos];
    }
    cout<<res;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1651 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 324 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
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 324 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 1 ms 340 KB Output is correct
12 Correct 1 ms 404 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 324 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 1 ms 340 KB Output is correct
12 Correct 1 ms 404 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 51 ms 8244 KB Output is correct
15 Correct 45 ms 8280 KB Output is correct
16 Incorrect 40 ms 7824 KB Output isn't correct
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1681 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1651 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -