| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1311728 | samarthkulkarni | Lightning Rod (NOI18_lightningrod) | C++17 | 272 ms | 79620 KiB |
#include <bits/stdc++.h>
using namespace std;
inline int readInt()
{
int x = 0;
char ch = getchar_unlocked();
while (ch < '0' || ch > '9')
ch = getchar_unlocked();
while (ch >= '0' && ch <= '9')
{
x = (x << 3) + (x << 1) + ch - '0';
ch = getchar_unlocked();
}
return x;
}
stack<pair<int, int>> s;
int main()
{
int N = readInt();
for (int i = 0; i < N; i++)
{
int x = readInt(), y = readInt();
bool add = true;
while (s.size())
{
auto [px, py] = s.top();
// * check if last rod covers current building
if (x - px <= py - y)
{
add = 0; // * no need to add a rod
break;
}
if (x - px <= y - py) // * ccheck if last rod is useless
s.pop();
else
break;
}
if (add)
s.push({x,y});
}
cout << s.size();
// write code here
return 0;
}| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
