답안 #970508

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
970508 2024-04-26T16:11:56 Z NoMercy Lightning Rod (NOI18_lightningrod) C++17
0 / 100
2000 ms 1948 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 <array <int , 2>> st;
    
    for (int i = 0;i < n;i ++) {
        int x , y;
        cin >> x >> y;
        array<int , 2> tmp = {x , y};
        if (st.size() == 0) {
            st.push({x , y});
            continue;
        }
        if (abs(x - st.top()[0]) <= st.top()[0] - y) {
            continue;
        }
        while ((int)st.size() > 0 && abs(st.top()[0] - x) <= y - st.top()[1]) {
            st.pop();
        }
        st.push({x , y});
    }
    cout << 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:24: warning: unused variable 'tmp' [-Wunused-variable]
   20 |         array<int , 2> tmp = {x , y};
      |                        ^~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2065 ms 660 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2055 ms 1948 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2065 ms 660 KB Time limit exceeded
2 Halted 0 ms 0 KB -