제출 #979144

#제출 시각아이디문제언어결과실행 시간메모리
979144MilosMilutinovicLightning Rod (NOI18_lightningrod)C++14
100 / 100
614 ms178196 KiB
#include <bits/stdc++.h> using namespace std; const int MAX = 10000005; int x[MAX], y[MAX]; stack<pair<int, int>> stk; int readint(){ int x=0,f=1; char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f; } int main() { int n, a, b, i; n = readint(); for (i = 0; i < n; i++) { a = readint(); b = readint(); int x = a - b; int y = a + b; while (!stk.empty() && stk.top().first >= x && stk.top().second <= y) { stk.pop(); } if (stk.empty() || stk.top().second < y) { stk.push({x, y}); } } printf("%d\n", (int) stk.size()); 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...