This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "towers.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
const ll INF=1e18+7;
const int LIM=1e5+7;
ll T[LIM], n;
void init(int _n, vector<int>_h) {
n=_n;
rep(i, n) T[i]=_h[i];
}
int max_towers(int l, int r, int d) {
ll akt=1, lst=INF, ans=1;
while(l<=r) {
if(akt==1) {
if(T[l]>lst) {
lst=T[l];
} else if(T[l]<=lst-d) {
lst=T[l];
++ans;
akt=0;
}
} else {
if(T[l]<lst) {
lst=T[l];
} else if(T[l]>=lst+d) {
lst=T[l];
++ans;
akt=1;
}
}
++l;
}
return ans/2;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |