답안 #341161

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
341161 2020-12-29T04:42:19 Z ommivorous Lightning Rod (NOI18_lightningrod) C++14
100 / 100
464 ms 157032 KB
#include <bits/stdc++.h> 
using namespace std; 
stack<pair<int,int> >s; 
inline int readInt() {
    int x=0; char ch=getchar_unlocked(); bool s=1;
    while(ch<'0'||ch>'9'){if(ch=='-')s=0;ch=getchar_unlocked();}
    while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar_unlocked();}
    return s?x:-x;
}

int main(){ 
    int n = readInt(); 
    for(int i=0;i<n;i++){
        int x = readInt();
        int y = readInt();
        bool add=1; 
        while(s.size()){ 
            int tx=s.top().first,ty=s.top().second; 
            if(x-tx<=ty-y){add=0;break;} 
            if(x-tx<=y-ty)s.pop(); 
            else break; 
        } 
        if(add)s.push(make_pair(x,y)); 
    } 
    printf("%d",(int)s.size()); 
} 
# 결과 실행 시간 메모리 Grader output
1 Correct 316 ms 81428 KB Output is correct
2 Correct 324 ms 80916 KB Output is correct
3 Correct 315 ms 78612 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 12 ms 1516 KB Output is correct
15 Correct 9 ms 1516 KB Output is correct
16 Correct 10 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 301 ms 52848 KB Output is correct
2 Correct 304 ms 52080 KB Output is correct
3 Correct 294 ms 50672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 316 ms 81428 KB Output is correct
2 Correct 324 ms 80916 KB Output is correct
3 Correct 315 ms 78612 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 12 ms 1516 KB Output is correct
18 Correct 9 ms 1516 KB Output is correct
19 Correct 10 ms 2284 KB Output is correct
20 Correct 301 ms 52848 KB Output is correct
21 Correct 304 ms 52080 KB Output is correct
22 Correct 294 ms 50672 KB Output is correct
23 Correct 430 ms 3180 KB Output is correct
24 Correct 464 ms 157032 KB Output is correct
25 Correct 460 ms 133740 KB Output is correct