Submission #742950

# Submission time Handle Problem Language Result Execution time Memory
742950 2023-05-17T06:48:45 Z Sainen420 Lightning Rod (NOI18_lightningrod) C++17
100 / 100
1712 ms 94376 KB
#include <bits/stdc++.h>
using namespace std;
using pi = pair<int,int>;

int xl,yl,x,y;
int ans=0,n;
stack<pi> s;
bool v=true;

int main()
{
    cin.tie(nullptr)->sync_with_stdio(false);
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x >> y;
        if(s.empty()){s.push({x,y});}
        v=true;
        while(true){
            if(s.empty())break;
            auto[xl,yl]=s.top();
            if(x-xl <= yl-y){//negative gradient = nom'd
                v=false;
                break;
            }
            if(x-xl <= y-yl){
                s.pop();
            }else{
                break;
            }
        }
        if(v)s.push({x,y});
    }
    cout << s.size();
    return 0;
}
/*
3
0 0
1 1
2 3
*/
# Verdict Execution time Memory Grader output
1 Correct 1347 ms 80660 KB Output is correct
2 Correct 1712 ms 94376 KB Output is correct
3 Correct 1459 ms 88840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 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 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 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 1 ms 212 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
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 320 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 316 KB Output is correct
7 Correct 1 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 1 ms 212 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 38 ms 3876 KB Output is correct
15 Correct 40 ms 3624 KB Output is correct
16 Correct 37 ms 3616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1400 ms 52820 KB Output is correct
2 Correct 1358 ms 60676 KB Output is correct
3 Correct 1351 ms 58944 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1347 ms 80660 KB Output is correct
2 Correct 1712 ms 94376 KB Output is correct
3 Correct 1459 ms 88840 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 0 ms 320 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 316 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 212 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 38 ms 3876 KB Output is correct
18 Correct 40 ms 3624 KB Output is correct
19 Correct 37 ms 3616 KB Output is correct
20 Correct 1400 ms 52820 KB Output is correct
21 Correct 1358 ms 60676 KB Output is correct
22 Correct 1351 ms 58944 KB Output is correct
23 Correct 1589 ms 14604 KB Output is correct
24 Correct 1592 ms 20480 KB Output is correct
25 Correct 1577 ms 20196 KB Output is correct