답안 #550932

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
550932 2022-04-19T12:01:38 Z AKiko Lightning Rod (NOI18_lightningrod) C++14
100 / 100
1681 ms 39928 KB
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ss second
#define ff first
#define pb push_back
#define pii pair<int, int>
#define INF INT_MAX
using namespace std;
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << ' ' << H; debug_out(T...); }
#ifdef AKIKO_DEBUG
#define debug(...) cerr << "\033[1;31m(" << #__VA_ARGS__ << "):\033[0m", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

#define FAST ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const ll MOD = 1e9 + 7;








int main() {
    FAST
    int n, mx = -1;
    cin >> n;
    stack<int> s;
    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        if(mx >= x + y) {
            continue;
        }
        mx = x + y;
        int d = x - y;
        while(s.size() > 0 && s.top() >= d) {
            s.pop();
        }
        s.push(d);
    }
    cout << s.size() << "\n";

    

    return 0;
}

/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?)
    * do smth instead of nothing and stay organized
    * WRITE STUFF DOWN
    * DON'T GET STUCK ON ONE APPROACH
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1407 ms 39928 KB Output is correct
2 Correct 1341 ms 39832 KB Output is correct
3 Correct 1340 ms 38784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 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 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 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 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 33 ms 296 KB Output is correct
15 Correct 40 ms 308 KB Output is correct
16 Correct 34 ms 588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1408 ms 25884 KB Output is correct
2 Correct 1414 ms 25764 KB Output is correct
3 Correct 1321 ms 25372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1407 ms 39928 KB Output is correct
2 Correct 1341 ms 39832 KB Output is correct
3 Correct 1340 ms 38784 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 33 ms 296 KB Output is correct
18 Correct 40 ms 308 KB Output is correct
19 Correct 34 ms 588 KB Output is correct
20 Correct 1408 ms 25884 KB Output is correct
21 Correct 1414 ms 25764 KB Output is correct
22 Correct 1321 ms 25372 KB Output is correct
23 Correct 1681 ms 332 KB Output is correct
24 Correct 1647 ms 432 KB Output is correct
25 Correct 1512 ms 1776 KB Output is correct