답안 #621283

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
621283 2022-08-03T16:26:44 Z PoonYaPat Lightning Rod (NOI18_lightningrod) C++14
100 / 100
1850 ms 210544 KB
#include <bits/stdc++.h>
using namespace std;

const int MX=10000005;
int n,a[MX],b[MX];
stack<int> st;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int i=1; i<=n; ++i) {
        int x,y;
        cin>>x>>y;
        a[i]=x-y;
        b[i]=x+y;
    }
    st.push(1);
    for (int i=2; i<=n; ++i) {
        int k=st.top();
        if (b[i]>b[st.top()]) {
            while (!st.empty() && a[i]<=a[st.top()]) st.pop();
            st.push(i);
        }
    }
    cout<<st.size();
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:19:13: warning: unused variable 'k' [-Wunused-variable]
   19 |         int k=st.top();
      |             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1594 ms 115832 KB Output is correct
2 Correct 1371 ms 115576 KB Output is correct
3 Correct 1487 ms 112404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 328 KB Output is correct
3 Correct 0 ms 328 KB Output is correct
4 Correct 1 ms 320 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 328 KB Output is correct
10 Correct 1 ms 324 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 1 ms 340 KB Output is correct
14 Correct 44 ms 5304 KB Output is correct
15 Correct 42 ms 5068 KB Output is correct
16 Correct 36 ms 4756 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1541 ms 103748 KB Output is correct
2 Correct 1540 ms 122144 KB Output is correct
3 Correct 1361 ms 113564 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1594 ms 115832 KB Output is correct
2 Correct 1371 ms 115576 KB Output is correct
3 Correct 1487 ms 112404 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 328 KB Output is correct
6 Correct 0 ms 328 KB Output is correct
7 Correct 1 ms 320 KB Output is correct
8 Correct 1 ms 328 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 328 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 44 ms 5304 KB Output is correct
18 Correct 42 ms 5068 KB Output is correct
19 Correct 36 ms 4756 KB Output is correct
20 Correct 1541 ms 103748 KB Output is correct
21 Correct 1540 ms 122144 KB Output is correct
22 Correct 1361 ms 113564 KB Output is correct
23 Correct 1804 ms 131588 KB Output is correct
24 Correct 1699 ms 112980 KB Output is correct
25 Correct 1850 ms 210544 KB Output is correct