이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
#define s second
#define f first
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
// const int INF = 1e17;
const int N = 2*1e5 + 10;
int main() {
int n, x;
cin >> n >> x;
vi vals(n);
vi dp(n);
vi cur;
for (int i = 0; i < n; i++) {
cin >> vals[i];
auto ind = lower_bound(cur.begin(), cur.end(), vals[i]) - cur.begin();
if (ind == cur.size()) cur.pb(vals[i]);
else cur[ind] = vals[i];
dp[i] = cur.size();
}
cur.erase(cur.begin(), cur.end());
int ans = 0;
for (int i = n-1; i >= 0; i--) {
int possible = lower_bound(cur.begin(), cur.end(), -vals[i] + x) - cur.begin();
// cout << i << possible << endl;
ans = max(ans, dp[i] + possible);
int ind = lower_bound(cur.begin(), cur.end(), -vals[i]) - cur.begin();
if (ind == cur.size()) cur.pb(-vals[i]);
else cur[ind]=vals[i];
}
cout << ans << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
glo.cpp: In function 'int main()':
glo.cpp:30:11: warning: comparison of integer expressions of different signedness: 'long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | if (ind == cur.size()) cur.pb(vals[i]);
| ~~~~^~~~~~~~~~~~~
glo.cpp:43:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | if (ind == cur.size()) cur.pb(-vals[i]);
| ~~~~^~~~~~~~~~~~~
# | 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... |