結果

問題 No.919 You Are A Project Manager
ユーザー finefine
提出日時 2019-10-26 00:35:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,212 bytes
コンパイル時間 1,927 ms
コンパイル使用メモリ 171,480 KB
実行使用メモリ 7,708 KB
最終ジャッジ日時 2023-10-11 12:47:38
合計ジャッジ時間 19,746 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,312 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 71 ms
4,348 KB
testcase_05 AC 84 ms
4,348 KB
testcase_06 AC 5 ms
4,352 KB
testcase_07 AC 1,428 ms
4,352 KB
testcase_08 AC 98 ms
4,348 KB
testcase_09 AC 53 ms
4,352 KB
testcase_10 AC 159 ms
4,348 KB
testcase_11 AC 142 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 239 ms
4,352 KB
testcase_14 AC 2 ms
4,352 KB
testcase_15 AC 25 ms
4,352 KB
testcase_16 AC 453 ms
4,348 KB
testcase_17 AC 1,295 ms
4,348 KB
testcase_18 AC 1,295 ms
4,352 KB
testcase_19 AC 2,302 ms
4,352 KB
testcase_20 TLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    ll ans = 0;
    for (int k = 1; k <= n; k++) {
        int max_num = n / k;
        vector<ll> memoL(max_num + 1, 0);
        ll tmp = 0;
        for (int i = 0; i < max_num; i++) {
            vector<ll> v(k);
            for (int j = 0; j < k; j++) {
                v[j] = a[i * k + j];
            }
            sort(v.begin(), v.end());
            tmp += v[(k - 1) / 2] * k;
            memoL[i + 1] = max(memoL[i], tmp);
        }

        vector<ll> memoR(max_num + 1, 0);
        tmp = 0;
        for (int i = 0; i < max_num; i++) {
            vector<ll> v(k);
            for (int j = 0; j < k; j++) {
                v[j] = a[n - 1 - i * k - j];
            }
            sort(v.begin(), v.end());
            tmp += v[(k - 1) / 2] * k;
            memoR[i + 1] = max(memoR[i], tmp);
        }

        for (int i = 0; i <= max_num; i++) {
            ans = max(ans, memoL[i] + memoR[max_num - i]);
        }
    }
    cout << ans << "\n";
    return 0;
}
0