# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1196800 | loom | Lightning Rod (NOI18_lightningrod) | C++20 | 472 ms | 117368 KiB |
#include <bits/stdc++.h>
using namespace std;
inline int readInt() {
int x = 0;
char ch = getchar();
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(){
int n = readInt();
vector<pair<int,int>> a(n);
for(int i = 0; i < n; i++) {
a[i].first = readInt();
a[i].second = readInt();
if(i > 0 and a[i].first == a[i-1].first) cout<<"haha";
}
int ans = n;
int mx = -1;
vector<int> tf(n, 0);
for(int i=0; i<n; i++){
auto [x, y] = a[i];
if(x+y <= mx) ans--, tf[i] = 1;
else mx = x+y;
}
int mn = 1e18;
for(int i=n-1; i>=0; i--){
if(tf[i]) continue;
auto [x, y] = a[i];
if(x-y >= mn) ans--;
else mn = x-y;
}
cout<<ans;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |