Submission #142395

# Submission time Handle Problem Language Result Execution time Memory
142395 2019-08-09T05:19:29 Z meatrow K blocks (IZhO14_blocks) C++17
0 / 100
5 ms 2552 KB
//#pragma GCC optimize("O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const int N = 1e5 + 5;
const int K = 105;

ll dp[K][N];
ll a[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        dp[1][i] = max(dp[1][i - 1], a[i]);
    }
    for (int i = 2; i <= k; i++) {
        vector<pair<ll, ll>> kek;
        for (int j = 1; j <= n; j++) {
            ll cur = dp[i - 1][j - 1];
            if (!cur) {
                cur = 1e12;
            }
            while (!kek.empty() && a[j] + cur <= max(kek.back().first, a[j]) + kek.back().second) {
                kek.pop_back();
            }
            if (kek.empty()) {
                kek.emplace_back(a[j], cur);
            }
            dp[i][j] = max(kek.back().first, a[j]) + kek.back().second;
        }
    }
    cout << dp[k][n];
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 248 KB Output is correct
4 Correct 2 ms 348 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 380 KB Output is correct
8 Correct 2 ms 380 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Incorrect 2 ms 376 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 380 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 2 ms 376 KB Output is correct
9 Correct 2 ms 376 KB Output is correct
10 Incorrect 2 ms 376 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 632 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 2552 KB Output isn't correct
2 Halted 0 ms 0 KB -