Submission #425589

# Submission time Handle Problem Language Result Execution time Memory
425589 2021-06-13T08:01:23 Z EleCursity Lightning Rod (NOI18_lightningrod) C++17
100 / 100
936 ms 191852 KB
#include <bits/stdc++.h>
using namespace std;
int readInt(){
    int x = 0;
    char ch = getchar();
    while (ch < '0' || ch > '9') ch = getchar();
    while (ch >= '0' && ch <= '9'){
        x = (x << 3) + (x << 1) + ch - '0';
        ch = getchar();
    }
    return x;
}
int main(){
  int n = readInt();
  stack<pair<int,int> > stk;
  for(int i=1;i<=n;i++){
    int x = readInt();
    int y = readInt();
    if(stk.empty()){
      stk.push({x,y});
    }
    else{
      while(!stk.empty()){
        int xx = stk.top().first;
        int yy = stk.top().second;
        if(yy>y){
          int dx = x-xx;
          int dy = yy-y;
          if(dy<dx){
              stk.push({x,y});
          }
          break;
        }
        int dx = x-xx;
        int dy = y-yy;
        if(dy>=dx){
          stk.pop();
        }else{
          stk.push({x,y});
          break;
        }
      }
      if(stk.empty()){
        stk.push({x,y});
      }

    }
  }
  cout<<stk.size()<<endl;
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 681 ms 146928 KB Output is correct
2 Correct 611 ms 191852 KB Output is correct
3 Correct 626 ms 186828 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 296 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 296 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 23 ms 3840 KB Output is correct
15 Correct 19 ms 3660 KB Output is correct
16 Correct 17 ms 3660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 633 ms 107628 KB Output is correct
2 Correct 625 ms 107488 KB Output is correct
3 Correct 599 ms 105048 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 681 ms 146928 KB Output is correct
2 Correct 611 ms 191852 KB Output is correct
3 Correct 626 ms 186828 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 296 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 296 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 23 ms 3840 KB Output is correct
18 Correct 19 ms 3660 KB Output is correct
19 Correct 17 ms 3660 KB Output is correct
20 Correct 633 ms 107628 KB Output is correct
21 Correct 625 ms 107488 KB Output is correct
22 Correct 599 ms 105048 KB Output is correct
23 Correct 936 ms 108352 KB Output is correct
24 Correct 868 ms 95932 KB Output is correct
25 Correct 851 ms 86152 KB Output is correct