Submission #987157

#TimeUsernameProblemLanguageResultExecution timeMemory
987157PyqeRadio Towers (IOI22_towers)C++17
0 / 100
4017 ms1860 KiB
#include <bits/stdc++.h> #include "towers.h" using namespace std; const long long inf=1e18; long long n,a[100069]; void init(int on,vector<int> aa) { long long i; n=on; for(i=1;i<=n;i++) { a[i]=aa[i-1]; } } int max_towers(int lb,int rb,int cw) { long long i,l=inf,c=0; lb++; rb++; for(i=lb;i<=rb;i++) { if(c%2==0) { if(a[i]<=l-cw) { c++; l=a[i]; } else if(a[i]>l) { l=a[i]; } } else { if(a[i]>=l+cw) { c++; l=a[i]; } else { l=a[i]; } } } return (c+1)/2; }
#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...