結果

問題 No.1977 Extracting at Constant Intervals
ユーザー 👑 NachiaNachia
提出日時 2022-06-10 23:48:03
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,752 bytes
コンパイル時間 1,697 ms
コンパイル使用メモリ 85,224 KB
実行使用メモリ 6,408 KB
最終ジャッジ日時 2023-10-21 05:53:08
合計ジャッジ時間 3,238 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 5 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 17 ms
5,616 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 16 ms
4,348 KB
testcase_11 WA -
testcase_12 AC 4 ms
4,348 KB
testcase_13 AC 17 ms
5,616 KB
testcase_14 AC 22 ms
6,408 KB
testcase_15 AC 11 ms
4,560 KB
testcase_16 AC 20 ms
6,144 KB
testcase_17 AC 19 ms
4,560 KB
testcase_18 AC 10 ms
4,348 KB
testcase_19 AC 6 ms
4,348 KB
testcase_20 AC 19 ms
5,088 KB
testcase_21 AC 15 ms
4,348 KB
testcase_22 AC 21 ms
6,144 KB
testcase_23 AC 5 ms
4,348 KB
testcase_24 AC 16 ms
4,348 KB
testcase_25 AC 4 ms
4,348 KB
testcase_26 AC 4 ms
4,348 KB
testcase_27 AC 10 ms
4,348 KB
testcase_28 AC 6 ms
4,348 KB
testcase_29 AC 12 ms
4,824 KB
testcase_30 AC 17 ms
4,824 KB
testcase_31 AC 10 ms
4,560 KB
testcase_32 AC 11 ms
4,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <atcoder/modint>
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(int)(n); i++)


const i64 INF = 1001001001001001001;
using modint = atcoder::static_modint<1000000007>;

int GCD(i64 a, i64 b){ return b ? GCD(b, a%b) : a; }


int main(){
    i64 N,M,L; cin >> N >> M >> L;
    vector<i64> A(N);
    rep(i,N) cin >> A[i];
    i64 B = GCD(N, L);
    i64 NbyB = N/B;

    i64 full_length = N * M;

    i64 ans = -INF * 2;

    vector<i64> permA(NbyB);
    vector<i64> indexPermA(NbyB);
    vector<i64> sum_permA(NbyB + 1);

    auto sum_permA_wide = [&](i64 l, i64 r) -> i64 {
        i64 lf = l % NbyB, rf = r % NbyB;
        i64 lH = l / NbyB, rH = r / NbyB;
        return sum_permA[rf] - sum_permA[lf] + (rH - lH) * sum_permA[NbyB];
    };

    rep(t,NbyB) indexPermA[t] = L%N*t%N;
    rep(s,B){
        rep(t,NbyB) permA[t] = A[s + indexPermA[t]];
        rep(t,NbyB) sum_permA[t+1] = sum_permA[t] + permA[t];
        
        rep(t,NbyB){
            i64 s_idx = s + indexPermA[t];
            if(L <= s) continue;
            i64 min_l_idx = s_idx;
            i64 max_l_idx = (L - s_idx - 1) / N * N + s_idx;
            if(min_l_idx > max_l_idx) continue;
            ans = max(ans, sum_permA_wide(t, t + (full_length - 1 - min_l_idx) / L + 1));
            ans = max(ans, sum_permA_wide(t, t + (full_length - 1 - max_l_idx) / L + 1));
        }
    }

    cout << ans << '\n';

    return 0;
}


struct ios_do_not_sync{
    ios_do_not_sync(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
    }
} ios_do_not_sync_instance;


0