답안 #1103957

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1103957 2024-10-22T12:57:47 Z vjudge1 Global Warming (CEOI18_glo) C++17
10 / 100
24 ms 3284 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 1;
const int INF = 2e9;
int arr[N] , ans;
int l[N] , r[N];
vector<int> dp;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,x; cin >> n >> x;
    for (int i=1;i<=n;i++) cin >> arr[i];
    for (int i=1;i<=n;i++) {
        int idx = lower_bound(dp.begin(), dp.end(), arr[i]) - dp.begin();
        l[i] = idx + 1;
        if (idx==dp.size()) dp.push_back(arr[i]);
        dp[idx] = arr[i];
    }
    dp.clear();
    for(int i=n;i>=1;i--) {
        int idx = lower_bound(dp.begin(), dp.end(), -arr[i] + x) - dp.begin();
        r[i] = idx + 1;
        if (idx==dp.size()) dp.push_back(arr[i]);
        dp[idx] = arr[i];
    }
    int ans = 0;
    for (int i=1;i<=n;i++) ans = max(ans, l[i] + r[i] - 1);
    cout << ans;
    return 0;
}

Compilation message

glo.cpp: In function 'int main()':
glo.cpp:16:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |         if (idx==dp.size()) dp.push_back(arr[i]);
      |             ~~~^~~~~~~~~~~
glo.cpp:23:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |         if (idx==dp.size()) dp.push_back(arr[i]);
      |             ~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 2640 KB Output is correct
2 Correct 23 ms 2776 KB Output is correct
3 Correct 24 ms 2640 KB Output is correct
4 Correct 24 ms 2632 KB Output is correct
5 Correct 17 ms 3284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 2640 KB Output is correct
2 Correct 8 ms 2640 KB Output is correct
3 Correct 7 ms 2640 KB Output is correct
4 Incorrect 5 ms 2896 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 17 ms 2896 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2384 KB Output isn't correct
2 Halted 0 ms 0 KB -