이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define pb push_back
#define ppb pop_back
#define ub upper_bound
#define lb lower_bound
#define bs binary_search
#define cl(a,s) memset((a),0,sizeof((a)[0])*(s))
#define all(x) (x).begin() , (x).end()
#define fi first
#define se second
#define int int
using pii = pair<int,int>;
using ll = long long;
const int maxn = 2e5+5;
const int inf = 2e9;
const int mod = 1e9+7;
int n,x;
int a[maxn];
int d[maxn];
int ans[maxn];
int tmp[maxn];
int lis() {
int ret = -1;
d[0] = -inf;
for(int i=1;i<=n;i++) d[i] = inf;
for(int i=1;i<=n;i++) {
int pos = lb(d,d+n+1,a[i])-d;
d[pos] = a[i];
ans[i] = pos;
ret = max(ret,pos);
}
return ret;
}
int32_t main () {
//freopen("in","r",stdin); freopen("out","w",stdout);
ios_base::sync_with_stdio(0); cout.tie(0); cin.tie(0);
cin >> n >> x;
for(int i=1;i<=n;i++) cin >> a[i];
for(int i=1;i<=n;i++) tmp[i] = a[i];
int ans = -inf;
for(int i=1;i<=n;i++)
for(int j=i;j<=n;j++)
for(int k=-x;k<=x;k++) {
for(int i=1;i<=j;i++) a[i] += k;
int res = lis();
if(res > ans) {
//cout << res << " " << ans << endl;
//cout << i << " " << j << " " << k << endl;
ans = res;
}
for(int i=1;i<=j;i++) a[i] = tmp[i];
}
cout << ans << 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... |