답안 #1083336

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1083336 2024-09-03T02:20:43 Z sh1ro Global Warming (CEOI18_glo) C++17
0 / 100
20 ms 4700 KB
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define fi first
#define se second
using namespace std;
const int N = 1e5 + 4;
const int oo = 1e18;
const int mod = (1 << 9);
int t, n, q, m, k, ans = 0, a[N], dp[N], f[N]{};
vector<int>v;

void solve(){
    cin >> n >> k;
    for (int i = 0; i < n; i++)cin >> a[i], dp[i] = oo;
    for (int i = 0; i < n; i++){
        m = upper_bound(dp, dp + n, a[i]) - dp;
        f[i] = m + 1;
        dp[m] = a[i];
        ans = max(ans, f[i]);
    }
    for (int i = 0; i < n; i++)dp[i] = oo;
    for (int i = n - 1; i >= 0; i--){
        m = lower_bound(dp, dp + n, k - a[i]) - dp;
        ans = max(ans, f[i] + m);
        m = upper_bound(dp, dp + n, -a[i]) - dp;
        dp[m] = -a[i];
    }
    cout << ans;
}
main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen("prime.inp", "r", stdin); freopen("prime.out", "w", stdout);
    t = 1;
    //cin >> t;
    while (t--)solve();
    return 0;
}

Compilation message

glo.cpp:31:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   31 | main() {
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 10 ms 4700 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 1880 KB Output is correct
2 Correct 10 ms 1984 KB Output is correct
3 Correct 11 ms 1884 KB Output is correct
4 Incorrect 11 ms 1940 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 3676 KB Output is correct
2 Correct 20 ms 3764 KB Output is correct
3 Runtime error 9 ms 4696 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -