Submission #1296191

#TimeUsernameProblemLanguageResultExecution timeMemory
1296191nathako9nLightning Rod (NOI18_lightningrod)C++20
4 / 100
137 ms1452 KiB
#include <bits/stdc++.h> using namespace std; static const int BUF = 1 << 20; static char ibuf[BUF]; static int ipos = 0, ilen = 0; inline char read() { if (ipos >= ilen) { ilen = fread(ibuf, 1, BUF, stdin); ipos = 0; if (ilen == 0) return 0; } return ibuf[ipos++]; } inline bool readInt(long long &x) { char c; do { c = read(); if (!c) return false; } while (c <= ' '); long long sign = 1; if (c == '-') { sign = -1; c = read(); } x = 0; while (c >= '0' && c <= '9') { x = x * 10 + (c - '0'); c = read(); } x *= sign; return true; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); long long N; readInt(N); long long x, y; long long cnt = 0; long long currentCover = LLONG_MIN; // จุดที่ใช้ครอบคลุมด้านขวา for (long long i = 0; i < N; i++) { readInt(x); readInt(y); long long L = y + x; long long R = y - x; // right endpoint if (i == 0) { cnt = 1; currentCover = R; } else { if (L > currentCover) { cnt++; currentCover = R; } else { currentCover = min(currentCover, R); } } } cout << cnt; 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...