結果

問題 No.919 You Are A Project Manager
ユーザー りあんりあん
提出日時 2019-10-25 21:48:59
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,663 bytes
コンパイル時間 2,312 ms
コンパイル使用メモリ 210,700 KB
実行使用メモリ 199,320 KB
最終ジャッジ日時 2023-10-01 00:20:48
合計ジャッジ時間 64,394 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,438 ms
199,208 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 80 ms
16,364 KB
testcase_05 AC 94 ms
18,476 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 654 ms
39,544 KB
testcase_08 AC 51 ms
6,336 KB
testcase_09 AC 29 ms
5,092 KB
testcase_10 AC 80 ms
8,072 KB
testcase_11 AC 73 ms
7,632 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 118 ms
10,204 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 14 ms
4,376 KB
testcase_16 AC 217 ms
15,764 KB
testcase_17 AC 1,805 ms
199,056 KB
testcase_18 AC 1,814 ms
199,128 KB
testcase_19 AC 2,293 ms
199,300 KB
testcase_20 TLE -
testcase_21 AC 2,433 ms
199,192 KB
testcase_22 AC 761 ms
45,288 KB
testcase_23 AC 723 ms
43,564 KB
testcase_24 AC 814 ms
48,208 KB
testcase_25 AC 756 ms
45,220 KB
testcase_26 TLE -
testcase_27 AC 2,386 ms
130,408 KB
testcase_28 TLE -
testcase_29 AC 1,824 ms
199,052 KB
testcase_30 AC 1,828 ms
199,152 KB
testcase_31 AC 1,580 ms
199,068 KB
testcase_32 AC 1,666 ms
199,032 KB
testcase_33 AC 895 ms
52,552 KB
testcase_34 AC 890 ms
52,564 KB
testcase_35 TLE -
testcase_36 TLE -
testcase_37 TLE -
testcase_38 TLE -
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 15 ms
4,484 KB
testcase_41 AC 3 ms
4,380 KB
testcase_42 AC 4 ms
4,376 KB
testcase_43 AC 6 ms
4,376 KB
testcase_44 AC 25 ms
4,816 KB
testcase_45 AC 3 ms
4,380 KB
testcase_46 AC 19 ms
4,476 KB
testcase_47 AC 763 ms
45,540 KB
testcase_48 AC 741 ms
44,460 KB
testcase_49 AC 838 ms
49,540 KB
testcase_50 AC 755 ms
45,100 KB
testcase_51 AC 643 ms
39,032 KB
testcase_52 AC 412 ms
26,548 KB
testcase_53 AC 644 ms
39,096 KB
testcase_54 AC 15 ms
4,376 KB
testcase_55 AC 2 ms
4,376 KB
testcase_56 AC 1 ms
4,380 KB
testcase_57 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int M = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    vector<vector<int>> mid(n + 1);
    for (int i = 1; i <= n; ++i) {
        mid[i] = vector<int>(i);
    }
    for (int i = 0; i < n; ++i) {
        priority_queue<int> lq;
        priority_queue<int, vector<int>, greater<int>> uq;
        lq.push(-M);
        uq.push(M);
        for (int j = i; j < n; ++j) {
            if (uq.top() > a[j]) {
                lq.push(a[j]);
            }
            else {
                uq.push(a[j]);
            }
            while (uq.size() > lq.size()) {
                lq.push(uq.top());
                uq.pop();
            }
            while (lq.size() > uq.size() + 1) {
                uq.push(lq.top());
                lq.pop();
            }
            mid[j + 1][i] = lq.top();
        }
    }
    long long ans = 0;
    for (int i = 1; i <= n; ++i) {
        vector<long long> sl(n / i + 1), sr(n / i + 1);
        vector<long long> ml(n / i + 1), mr(n / i + 1);
        for (int j = 0; j < n / i; ++j) {
            sl[j + 1] = sl[j] + mid[(j + 1) * i][j * i] * (long long)i;
            ml[j + 1] = max(ml[j], sl[j + 1]);
        }
        for (int j = 0; j < n / i; ++j) {
            sr[j + 1] = sr[j] + mid[n - j * i][n - (j + 1) * i] * (long long)i;
            mr[j + 1] = max(mr[j], sr[j + 1]);
        }
        for (int j = 0; j < n / i; ++j) {
            ans = max(ans, ml[j] + mr[n / i - j]);
        }
    }
    cout << ans << '\n';

    return 0;
}
0