답안 #197444

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
197444 2020-01-21T09:02:11 Z quocnguyen1012 Lightning Rod (NOI18_lightningrod) C++14
80 / 100
2000 ms 144724 KB
#include <bits/stdc++.h>

int hmt() {int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';if(n) x=-x;return x;}
#define in hmt()
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;

signed main(void)
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  if (fopen("A.INP", "r")){
    freopen("A.INP", "r", stdin);
    freopen("A.OUT", "w", stdout);
  }
  int N = in;
  stack<pair<int, int>> ST;
  while (N--){
    int x = in, y = in;
    bool ok = 1;
    while (ST.size()){
      auto now = ST.top();
      if (x - now.fi <= now.se - y){
        ok = false;
        break;
      }
      else if (x - now.fi <= y - now.se){
        ST.pop();
      }
      else break;
    }
    if (ok){
      ST.push(mp(x, y));
    }
  }
  cout << (int)ST.size() << '\n';
}

Compilation message

lightningrod.cpp: In function 'int main()':
lightningrod.cpp:17:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("A.INP", "r", stdin);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
lightningrod.cpp:18:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("A.OUT", "w", stdout);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1759 ms 99912 KB Output is correct
2 Correct 1749 ms 98208 KB Output is correct
3 Correct 1705 ms 90752 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 424 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 296 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 424 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 296 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 424 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 296 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 504 KB Output is correct
2 Correct 2 ms 424 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 296 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 3 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 3 ms 376 KB Output is correct
14 Correct 55 ms 3960 KB Output is correct
15 Correct 52 ms 3704 KB Output is correct
16 Correct 47 ms 3704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1562 ms 57060 KB Output is correct
2 Correct 1574 ms 144724 KB Output is correct
3 Correct 1514 ms 142268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1759 ms 99912 KB Output is correct
2 Correct 1749 ms 98208 KB Output is correct
3 Correct 1705 ms 90752 KB Output is correct
4 Correct 2 ms 504 KB Output is correct
5 Correct 2 ms 424 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 296 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 3 ms 376 KB Output is correct
13 Correct 2 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 55 ms 3960 KB Output is correct
18 Correct 52 ms 3704 KB Output is correct
19 Correct 47 ms 3704 KB Output is correct
20 Correct 1562 ms 57060 KB Output is correct
21 Correct 1574 ms 144724 KB Output is correct
22 Correct 1514 ms 142268 KB Output is correct
23 Execution timed out 2033 ms 138264 KB Time limit exceeded
24 Halted 0 ms 0 KB -