답안 #970511

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970511 2024-04-26T16:14:08 Z NoMercy Lightning Rod (NOI18_lightningrod) C++14
66 / 100
2000 ms 43256 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 << (int)st.size() << "\n";
}

 
int32_t main () {
 
    ///    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 Execution timed out 2019 ms 43256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 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 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 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 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 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 2 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 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 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 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 2 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 101 ms 3864 KB Output is correct
15 Correct 95 ms 3664 KB Output is correct
16 Correct 93 ms 4304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2037 ms 29512 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2019 ms 43256 KB Time limit exceeded
2 Halted 0 ms 0 KB -