이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MAXN = 2e5 + 5;
ll n, x, arr[MAXN], ans = 0;
void update(ll l, ll r, ll x) {
for (int i = l; i <= r; ++i)
{
arr[i] += x;
}
}
ll lis() {
vector<ll> nowvec;
for (int i = 1; i <= n; ++i)
{
ll now = arr[i];
ll idx = lower_bound(nowvec.begin(), nowvec.end(), now) - nowvec.begin();
if (idx == nowvec.size()) {
nowvec.push_back(now);
} else {
nowvec[idx] = now;
}
}
return nowvec.size();
}
int main(){
cin >> n >> x;
for (int i = 1; i <= n; ++i)
{
cin >> arr[i];
}
ans = lis();
if (x == 0)
{
cout << ans << "\n";
return 0;
}
for (int i = 1; i <= n; ++i)
{
for (int j = i; j <= n; ++j)
{
for (int k = -x; k <= x; ++k)
{
update(i, j, k);
ans = max(ans, lis());
update(i, j, -k);
}
}
}
cout << ans << "\n";
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
glo.cpp: In function 'll lis()':
glo.cpp:21:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
21 | if (idx == nowvec.size()) {
| ~~~~^~~~~~~~~~~~~~~~
# | 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... |