Submission #599883

#TimeUsernameProblemLanguageResultExecution timeMemory
599883starchanLightning Rod (NOI18_lightningrod)C++17
0 / 100
333 ms156876 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define in pair<int, int> #define f first #define s second #define pb push_back #define pob pop_back #define INF (int)1e17 #define MX (int)3e5+5 #define fast() ios_base::sync_with_stdio(false); cin.tie(NULL) inline int readInt() { int x = 0; char ch=getchar_unlocked(); bool st = 1; while(ch < '0' || ch > '9'){if(ch=='-')st=0; ch=getchar_unlocked();} while(ch>='0'&&ch<='9'){x = (x<<3)+(x<<1)+ch-'0';ch=getchar_unlocked();} return st?x:-x; } vector<int> add(1e7+1, 0); vector<int> sub(1e7+1, 0); signed main() { fast(); int n = readInt(); for(int i = 1; i <= n; i++) { int x, y; x = readInt(); y = readInt(); add[i] = x+y; sub[i] = y-x; } for(int i = 2; i <= n; i++) add[i] = max(add[i], add[i-1]); for(int i = n-1; i >= 1; i--) sub[i] = max(sub[i], sub[i+1]); int ans = 0; for(int i = 1; i <= n; i++) ans+=(((i==1)||(add[i] > add[i+1]))&&((i==n)||(sub[i] > sub[i+1]))); cout << ans; 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...