제출 #1135385

#제출 시각아이디문제언어결과실행 시간메모리
1135385AutoratchLightning Rod (NOI18_lightningrod)C++20
100 / 100
389 ms79608 KiB
#include <bits/stdc++.h>
using namespace std;

int n,x,y;
stack<pair<int,int> > a;

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;
}

int main()
{
    n = readInt();
    for(int i = 0;i < n;i++)
    {
        x = readInt(),y = readInt();
        while(!a.empty() and abs(a.top().first-x)<=y-a.top().second) a.pop();
        if(a.empty() or abs(a.top().first-x)>a.top().second-y) a.push({x,y});
    }
    printf("%d",(int)a.size());
}
#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...