답안 #544690

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
544690 2022-04-02T14:28:39 Z AbdelmagedNour Lightning Rod (NOI18_lightningrod) C++17
40 / 100
2000 ms 130552 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int N=10000005;
int 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++){
        int x,y;
        cin>>x>>y;
        a[i]=y-x;
        b[i]=y+x;
    }
    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);
    }
    int res=0,pos=0,mx=INT_MIN;
    while(pos<n){
        if(b[pos]<=mx){
            pos++;
            continue;
        }
        res++;
        while(nxta[pos]!=-1)pos=nxta[pos];
        mx=max(mx,b[pos]);
        pos=nxtb[pos];
    }
    cout<<res;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2098 ms 130552 KB Time limit exceeded
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 340 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 340 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 328 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 340 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 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 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 340 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 328 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 55 ms 3232 KB Output is correct
15 Correct 65 ms 3388 KB Output is correct
16 Execution timed out 2055 ms 3364 KB Time limit exceeded
17 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2013 ms 123096 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2098 ms 130552 KB Time limit exceeded
2 Halted 0 ms 0 KB -