Submission #146996

#TimeUsernameProblemLanguageResultExecution timeMemory
146996jun6873Lightning Rod (NOI18_lightningrod)C++11
66 / 100
2057 ms183868 KiB
#include <bits/stdc++.h> using namespace std; using lint = long long; using pint = pair<lint, lint>; #define x first #define y second const int maxn = 10000004; int n, k, b[maxn]; pint a[maxn]; //https://www.geeksforgeeks.org/fast-io-for-competitive-programming/ void fastscan(int &number) { //variable to indicate sign of input number bool negative = false; register int c; number = 0; // extract current character from buffer c = getchar(); if (c=='-') { // number is negative negative = true; // extract the next character from the buffer c = getchar(); } // Keep on extracting characters if they are integers // i.e ASCII Value lies from '0'(48) to '9' (57) for (; (c>47 && c<58); c=getchar()) number = number *10 + c - 48; // if scanned input has a negative sign, negate the // value of the input number if (negative) number *= -1; } int main() { ios::sync_with_stdio(0); cin.tie(0); fastscan(n); for (int i=0; i<n; i++) { int x, y; fastscan(x); fastscan(y); a[i] = pint(x+y, y-x); } sort(a, a+n); reverse(a, a+n); n = unique(a, a+n, [](pint x, pint y) { return x.x == y.x; }) - a; reverse(a, a+n); for (int i=0; i<n; i++) { while (k and b[k-1] <= a[i].y) k--; b[k++] = a[i].y; } cout << k << '\n'; }
#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...