Submission #573224

#TimeUsernameProblemLanguageResultExecution timeMemory
573224guugiuhLightning Rod (NOI18_lightningrod)C++14
100 / 100
565 ms262144 KiB
#include <bits/stdc++.h> #include <iostream> #include <cstdio> #include <cstdlib> #include <vector> using namespace std; inline int readInt() { int x = 0; char ch = getchar_unlocked(); 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 MinPyramids(int N, vector<int>X, vector<int>Y) { int ms=-20;int n=N; vector<int>v(N,1); for(int i=0;n>i;++i)if(X[i]+Y[i]>ms)ms=X[i]+Y[i];else v[i]=0; ms=-2e9; for(int i=n-1;i>=0;--i)if(-X[i]+Y[i]>ms)ms=-X[i]+Y[i];else v[i]=0; int t=0; for(int i=0;n>i;++i)t+=v[i]; return t; } int main(){ int N = readInt(); vector <int> X(N); vector <int> Y(N); for(int i = 0; i < N; i++) { X[i] = readInt(); Y[i] = readInt(); } int ans= MinPyramids(N,X,Y); printf("%d", 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...