답안 #169233

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
169233 2019-12-19T07:45:03 Z aggu_01000101 Lightning Rod (NOI18_lightningrod) C++14
100 / 100
510 ms 262144 KB
    #include <iostream>
    #include <algorithm>
    #include <cmath>
    #include <unordered_map>
    #include <fstream>
    #include <stack>
    #include <vector>
    #include <set>
    #include <queue>
    #include <cstdlib>
    #include <cstring>
    #include <map>
    #define int long long
    using namespace std;
    inline int readInt() {
        int x = 0;
        char ch = getchar_unlocked();
        while (ch < '0' || ch > '9') ch = getchar_unlocked();
        while (ch >= '0' && ch <= '9'){
            x = (x << 3) + (x << 1) + ch - '0';
            ch = getchar_unlocked();
        }
        return x;
    }
    int32_t main(){
        ios_base::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        int n = readInt();
        stack<pair<int, int>> st;
        for(int i =0 ;i<n;i++){
            int x = readInt(), y = readInt();
            bool toadd = true;
            bool cont = true;
            while(st.size() && cont){
                if(abs(x - st.top().first)<=(st.top().second - y)) toadd = cont = false;
                else if(abs(x - st.top().first)<=(y-st.top().second)) st.pop();
                else cont = false;
            }
            if(toadd) st.push(make_pair(x, y));
        }
        cout<<st.size()<<endl;
    }
# 결과 실행 시간 메모리 Grader output
1 Correct 468 ms 160612 KB Output is correct
2 Correct 493 ms 262144 KB Output is correct
3 Correct 479 ms 262144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 420 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 420 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 420 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 420 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 420 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 420 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 420 KB Output is correct
3 Correct 2 ms 380 KB Output is correct
4 Correct 2 ms 420 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 504 KB Output is correct
14 Correct 12 ms 2936 KB Output is correct
15 Correct 12 ms 1656 KB Output is correct
16 Correct 13 ms 3064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 438 ms 104560 KB Output is correct
2 Correct 459 ms 198668 KB Output is correct
3 Correct 444 ms 193656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 468 ms 160612 KB Output is correct
2 Correct 493 ms 262144 KB Output is correct
3 Correct 479 ms 262144 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 420 KB Output is correct
6 Correct 2 ms 380 KB Output is correct
7 Correct 2 ms 420 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Correct 2 ms 380 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 2 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 2 ms 376 KB Output is correct
15 Correct 2 ms 376 KB Output is correct
16 Correct 2 ms 504 KB Output is correct
17 Correct 12 ms 2936 KB Output is correct
18 Correct 12 ms 1656 KB Output is correct
19 Correct 13 ms 3064 KB Output is correct
20 Correct 438 ms 104560 KB Output is correct
21 Correct 459 ms 198668 KB Output is correct
22 Correct 444 ms 193656 KB Output is correct
23 Correct 510 ms 175264 KB Output is correct
24 Correct 460 ms 155856 KB Output is correct
25 Correct 456 ms 141356 KB Output is correct