답안 #970512

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970512 2024-04-26T16:15:11 Z NoMercy Lightning Rod (NOI18_lightningrod) C++14
100 / 100
1481 ms 192080 KB
#include <bits/stdc++.h>
using namespace std;
 
    
int TIME = clock();

#define file \
            freopen("in.txt" , "r" , stdin); \
            freopen("out.txt" , "w" , stdout);
 

void test_case () {
    int n;
    cin >> n;
    stack<pair<int , int>> st;
    
    for (int i = 0;i < n;i ++) {
        int x , y;
        cin >> x >> y;
        pair<int , int> tmp = {x , y};
        if (st.size() == 0) {
            st.push({x , y});
            continue;
        }
        if (abs(x - st.top().first) <= st.top().second - y) {
            continue;
        }
        while ((int)st.size() > 0 && abs(st.top().first - x) <= y - st.top().second) {
            st.pop();
        }
        st.push({x , y});
    }
    cout << st.size() << "\n";
}

 
int32_t main () {

    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
     ///   file
    
 
    int t = 1;
    // cin >> t;
 
    while (t --) {
        test_case();
    }

    return 0;
}

Compilation message

lightningrod.cpp: In function 'void test_case()':
lightningrod.cpp:20:25: warning: variable 'tmp' set but not used [-Wunused-but-set-variable]
   20 |         pair<int , int> tmp = {x , y};
      |                         ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1176 ms 131216 KB Output is correct
2 Correct 1223 ms 192080 KB Output is correct
3 Correct 1258 ms 186748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 27 ms 704 KB Output is correct
15 Correct 27 ms 348 KB Output is correct
16 Correct 25 ms 1116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1156 ms 91048 KB Output is correct
2 Correct 1257 ms 147476 KB Output is correct
3 Correct 1230 ms 144004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1176 ms 131216 KB Output is correct
2 Correct 1223 ms 192080 KB Output is correct
3 Correct 1258 ms 186748 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 27 ms 704 KB Output is correct
18 Correct 27 ms 348 KB Output is correct
19 Correct 25 ms 1116 KB Output is correct
20 Correct 1156 ms 91048 KB Output is correct
21 Correct 1257 ms 147476 KB Output is correct
22 Correct 1230 ms 144004 KB Output is correct
23 Correct 1481 ms 175636 KB Output is correct
24 Correct 1341 ms 156936 KB Output is correct
25 Correct 1253 ms 140356 KB Output is correct