Submission #668632

#TimeUsernameProblemLanguageResultExecution timeMemory
668632600MihneaLightning Rod (NOI18_lightningrod)C++17
100 / 100
356 ms76360 KiB
#include <bits/stdc++.h>


using namespace std;

inline void read(int& x) {
    x = 0;
    char ch = getchar_unlocked();
    while (ch&16){
		x = (x << 3) + (x << 1) + (ch&15);
		ch = getchar_unlocked();
	}
}


struct T
{
  int x;
  int y;
};

bool eat(T a, T b)
{
  return a.x <= b.x && a.y <= b.y;
}

signed main()
{
  int n;
  read(n);
  vector<T> stk;
  stk.reserve(n);
  for (int i = 1; i <= n; i++)
  {
    int x, y;
    read(x);
    read(y);
    T cur = {-x - y, x - y};
    if (stk.empty())
    {
      stk.push_back(cur);
    }
    else
    {
      if (eat(stk.back(), cur))
      {
        continue;
      }
      while (!stk.empty() && eat(cur, stk.back()))
      {
        stk.pop_back();
      }
      stk.push_back(cur);
    }
  }
  cout << (int) stk.size() << "\n";
  return 0;
}
#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...