Submission #197444

#TimeUsernameProblemLanguageResultExecution timeMemory
197444quocnguyen1012Lightning Rod (NOI18_lightningrod)C++14
80 / 100
2033 ms144724 KiB
#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 (stderr)

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);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...