| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1297192 | chaitanyamehta | Lightning Rod (NOI18_lightningrod) | C++20 | 1077 ms | 234320 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int N;
if (scanf("%d", &N) != 1) return 0;
vector<ll> A(N), B(N);
for (int i = 0; i < N; ++i) {
ll X, Y;
scanf("%lld %lld", &X, &Y);
A[i] = X + Y; // used for right coverage
B[i] = Y - X; // used for left coverage
}
// suffix max of A
vector<ll> suffA(N);
suffA[N-1] = A[N-1];
for (int i = N - 2; i >= 0; --i) {
suffA[i] = max(A[i], suffA[i+1]);
}
ll rods = 0;
ll prefMinB = LLONG_MAX; // min of B[0..i-1]
for (int i = 0; i < N; ++i) {
bool coveredLeft = (i > 0 && prefMinB <= B[i]); // some j < i with B[j] <= B[i]
bool coveredRight = (i + 1 < N && suffA[i+1] >= A[i]); // some j > i with A[j] >= A[i]
if (!coveredLeft && !coveredRight) ++rods;
prefMinB = min(prefMinB, B[i]);
}
printf("%lld\n", rods);
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... | ||||
