이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define sherina ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define int long long
#define INF 1e18
#define endl '\n'
using namespace std;
int n , x , t[200005];
vector < int > v;
signed main(){
cin >> n >> x;
for(int i = 1 ; i <= n ; i++) cin >> t[i];
int maks = 0;
for(int i = 1 ; i <= n ; i++){
for(int j = i ; j <= n ; j++){
for(int k = -x ; k <= x ; k++){
v.clear();
for(int l = i ; l <= j ; l++) t[l] += k;
for(int l = 1 ; l <= n ; l++){
int tmp = v.size();
if(!tmp) v.pb(t[l]);
else if(t[l] > v[tmp - 1]) v.pb(t[l]);
else{
int id = lower_bound(v.begin() , v.end() , t[l]) - v.begin();
v[id] = t[l];
}
}
for(int l = i ; l <= j ; l++) t[l] -= k;
int sie = v.size();
//cout << i << " " << j << " " << k << " " << sie << endl;
maks = max(maks , sie);
}
}
}
cout << maks << endl;
}
# | 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... |