이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
int main(){
int n, x;
cin >> n >> x;
int a[n];
for (int i=0; i<n; i++)
cin >> a[i];
int dp[n + 1] = {0};
for (int i = 1; i <= n; i ++)
dp[i] = inf;
int ans = 0;
int pref[n] = {0};
for (int i = 0; i < n; i ++){
int ub = lower_bound(dp, dp + n + 1, a[i]) - dp;
dp[ub] = a[i];
ans = max(ans, ub);
pref[i] = ub;
}
if (x == 0){
cout << ans << endl;
return 0;
}
int cpy[n];
if (n <= 50 and x <= 50){
for (int d = -x; d <= x; d++){
for (int l = 0; l < n; l ++){
for (int r = l; r < n; r ++){
for (int i = 0; i < n; i ++)
cpy[i] = a[i] + d * (l <= i and i <= r);
for (int i = 1; i <= n; i++)
dp[i] = inf;
dp[0] = -inf;
for (int i = 0; i < n; i ++){
int ub = lower_bound(dp, dp + n + 1, cpy[i]) - dp;
dp[ub] = cpy[i];
ans = max(ans, ub);
}
}
}
}
cout << ans << endl;
return 0;
}
if (x < 6){
for (int d = -x; d <= x; d ++){
for (int i = 1; i <= n; i++)
dp[i] = inf;
dp[0] = -inf;
for (int i = n - 1; i >= 0; i--){
int ub = lower_bound(dp, dp + n + 1, -(a[i] + d)) - dp;
dp[ub] = -(a[i] + d);
ans = max(ans, pref[i] + ub);
}
}
cout << ans << endl;
return 0;
}
cout << 1 / 0 << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
glo.cpp: In function 'int main()':
glo.cpp:73:15: warning: division by zero [-Wdiv-by-zero]
73 | cout << 1 / 0 << 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... |