Submission #75468872


Source Code Expand

#line 2 "/Users/blue_jam/ProconLibrary/misc/template.hpp"

#include <atcoder/all>
#include <bits/stdc++.h>

using namespace std;
using namespace atcoder;

#define ALL(x) (x).begin(), (x).end()

using ll = long long;
#ifndef EPS
const double eps = 1e-10;
#else
const double eps = EPS;
#endif
#line 2 "abc456/F/main.cpp"


// K = 2
// A = 1 1000 1
const ll INF = 1e18;

using S = vector<vector<ll>>;

S op(S a, S b) {
    ll n = a.size(), m = b[0].size();
    S c(n, vector<ll>(m, INF));
    for (ll i = 0; i < n; i++) {
        for (ll j = 0; j < m; j++) {
            for (ll k = 0; k < a[i].size(); k++) {
                c[i][j] = min(c[i][j], a[i][k] + b[k][j]);
            }
        }
    }
    return c;
}

S e() {
    vector r(2, vector<ll>(2, INF));
    r[0][0] = r[1][1] = 0;
    return r;
}

int main() {
    ll T;
    cin >> T;
    for (; T--;) {
        ll N, K;
        cin >> N >> K;
        vector<ll> A(N);
        vector<S> B(N, vector(2, vector<ll>(2)));
        for (ll i = 0; i < N; i++) {
            cin >> A[i];
            B[i][0][0] = A[i];
            B[i][0][1] = A[i];
            B[i][1][0] = 0;
            B[i][1][1] = INF;
        }
        segtree<S, op, e> seg(B);
        ll ans = INF;
        for (ll k = K; k <= K + 1; k++) {
            for (ll i = 0; i + k <= N; i++) {
                S t = seg.prod(i, i + k - 1);
                S u(2, vector<ll>(1));
                u[0][0] = A[i + k - 1];
                u[1][0] = INF;
                S v = op(t, u);
                ans = min(ans, v[0][0]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Submission Info

Submission Time
Task F - Plan Holidays
User blue_jam
Language C++23 (GCC 15.2.0)
Score 525
Code Size 1688 Byte
Status AC
Exec Time 1045 ms
Memory 112448 KiB

Compile Error

abc456/F/main.cpp: In function 'S op(S, S)':
abc456/F/main.cpp:15:30: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 525 / 525
Status
AC × 1
AC × 57
Set Name Test Cases
Sample 00_sample_01.txt
All 00_sample_01.txt, 01_small_random_01.txt, 01_small_random_02.txt, 01_small_random_03.txt, 02_medium_random_01.txt, 02_medium_random_02.txt, 02_medium_random_03.txt, 03_large_random_01.txt, 03_large_random_02.txt, 03_large_random_03.txt, 04_max_n_01.txt, 04_max_n_02.txt, 04_max_n_03.txt, 04_max_n_04.txt, 05_hand_01.txt, 05_hand_02.txt, 05_hand_03.txt, 05_hand_04.txt, 05_hand_05.txt, 05_hand_06.txt, 05_hand_07.txt, 05_hand_08.txt, 05_hand_09.txt, 05_hand_10.txt, 05_hand_11.txt, 05_hand_12.txt, 05_hand_13.txt, 05_hand_14.txt, 05_hand_15.txt, 05_hand_16.txt, 05_hand_17.txt, 05_hand_18.txt, 05_hand_19.txt, 05_hand_20.txt, 05_hand_21.txt, 05_max_01.txt, 06_hand_01.txt, 06_hand_02.txt, 06_hand_03.txt, 06_hand_04.txt, 06_hand_05.txt, 06_hand_06.txt, 06_hand_07.txt, 06_hand_08.txt, 06_hand_09.txt, 06_hand_10.txt, 06_hand_11.txt, 06_hand_12.txt, 06_hand_13.txt, 06_hand_14.txt, 06_hand_15.txt, 06_hand_16.txt, 06_hand_17.txt, 06_hand_18.txt, 06_hand_19.txt, 06_hand_20.txt, 06_hand_21.txt
Case Name Status Exec Time Memory
00_sample_01.txt AC 1 ms 3620 KiB
01_small_random_01.txt AC 364 ms 3644 KiB
01_small_random_02.txt AC 363 ms 3568 KiB
01_small_random_03.txt AC 362 ms 3696 KiB
02_medium_random_01.txt AC 560 ms 16016 KiB
02_medium_random_02.txt AC 518 ms 15748 KiB
02_medium_random_03.txt AC 473 ms 10336 KiB
03_large_random_01.txt AC 627 ms 108276 KiB
03_large_random_02.txt AC 896 ms 107976 KiB
03_large_random_03.txt AC 463 ms 106884 KiB
04_max_n_01.txt AC 378 ms 112252 KiB
04_max_n_02.txt AC 738 ms 112328 KiB
04_max_n_03.txt AC 742 ms 112388 KiB
04_max_n_04.txt AC 177 ms 112340 KiB
05_hand_01.txt AC 596 ms 112296 KiB
05_hand_02.txt AC 604 ms 112260 KiB
05_hand_03.txt AC 981 ms 112448 KiB
05_hand_04.txt AC 788 ms 112328 KiB
05_hand_05.txt AC 431 ms 112372 KiB
05_hand_06.txt AC 804 ms 112320 KiB
05_hand_07.txt AC 351 ms 112304 KiB
05_hand_08.txt AC 858 ms 112324 KiB
05_hand_09.txt AC 217 ms 112260 KiB
05_hand_10.txt AC 420 ms 112440 KiB
05_hand_11.txt AC 623 ms 112440 KiB
05_hand_12.txt AC 1025 ms 112408 KiB
05_hand_13.txt AC 1045 ms 112324 KiB
05_hand_14.txt AC 393 ms 112340 KiB
05_hand_15.txt AC 497 ms 16436 KiB
05_hand_16.txt AC 489 ms 16480 KiB
05_hand_17.txt AC 613 ms 16432 KiB
05_hand_18.txt AC 621 ms 16480 KiB
05_hand_19.txt AC 644 ms 16196 KiB
05_hand_20.txt AC 563 ms 16452 KiB
05_hand_21.txt AC 695 ms 16336 KiB
05_max_01.txt AC 177 ms 112372 KiB
06_hand_01.txt AC 592 ms 112260 KiB
06_hand_02.txt AC 608 ms 112388 KiB
06_hand_03.txt AC 980 ms 112324 KiB
06_hand_04.txt AC 790 ms 112440 KiB
06_hand_05.txt AC 429 ms 112328 KiB
06_hand_06.txt AC 802 ms 112296 KiB
06_hand_07.txt AC 350 ms 112300 KiB
06_hand_08.txt AC 859 ms 112296 KiB
06_hand_09.txt AC 215 ms 112324 KiB
06_hand_10.txt AC 353 ms 112324 KiB
06_hand_11.txt AC 619 ms 112440 KiB
06_hand_12.txt AC 1027 ms 112328 KiB
06_hand_13.txt AC 1044 ms 112328 KiB
06_hand_14.txt AC 391 ms 112328 KiB
06_hand_15.txt AC 496 ms 16272 KiB
06_hand_16.txt AC 492 ms 16484 KiB
06_hand_17.txt AC 607 ms 16488 KiB
06_hand_18.txt AC 623 ms 16440 KiB
06_hand_19.txt AC 639 ms 16412 KiB
06_hand_20.txt AC 562 ms 16312 KiB
06_hand_21.txt AC 694 ms 16504 KiB