제출 #581319

#제출 시각아이디문제언어결과실행 시간메모리
581319drdilyorGlobal Warming (CEOI18_glo)C++17
15 / 100
2093 ms4552 KiB
#if defined(ONPC) && !defined(_GLIBCXX_ASSERTIONS)
    #define _GLIBCXX_ASSERTIONS
#endif
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#ifdef ONPC
    #include "t_debug.cpp"
#else
    #define debug(...) 42
#endif
#define allit(a) (a).begin(), (a).end()
#define sz(a) ((int) (a).size())

using namespace std;
using ll = long long;
using vi = vector<int>;
namespace pd = __gnu_pbds;
template<typename K>
using ordered_set = pd::tree<K, pd::null_type, less<int>, pd::rb_tree_tag, pd::tree_order_statistics_node_update>;
template<typename... T>
using gp_hash_table = pd::gp_hash_table<T...>;//simple using statement gives warnings

const int INF = 1e9;
const ll INFL = 1e18;
const int N = 1e5;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);

int lis(vi& a) {
    vi dp(a.size());
    int res = 0;
    for (int i = 0; i < sz(a); i++) {
        dp[i] = 1;
        for (int j = 0; j < i; j++) {
            if (a[j] < a[i]) dp[i] = max(dp[i], dp[j]+1);
        }
        res = max(res, dp[i]);
    }
    debug(a, res);
    return res;
}

int solve() {
    int n, x; cin >> n >> x;
    vi a(n); for (auto& i : a) cin >> i;

    int res = 0;
    for (int d = -x; d <= x; d++) {
        vi b = a;
        for (int i = 0; i < n; i++) {
            b[i] += d;
            res =max(res, lis(b));
        }
        b = a;
        for (int i = n-1; i >= 0; i--) {
            b[i] += d;
            res = max(res, lis(b));
        }
    }
    cout << res;
    return 0;
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int t = 1;
    //cin >> t;
    while (t-- && cin) {
        if (solve()) break;
        #ifdef ONPC
            cout << "____________________" << endl;
        #endif
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

glo.cpp: In function 'int lis(vi&)':
glo.cpp:10:24: warning: statement has no effect [-Wunused-value]
   10 |     #define debug(...) 42
      |                        ^~
glo.cpp:40:5: note: in expansion of macro 'debug'
   40 |     debug(a, res);
      |     ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...