結果
問題 | No.919 You Are A Project Manager |
ユーザー | machy |
提出日時 | 2019-10-25 23:48:34 |
言語 | C++17(clang) (17.0.6 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2,534 ms / 3,000 ms |
コード長 | 2,280 bytes |
コンパイル時間 | 1,023 ms |
コンパイル使用メモリ | 130,640 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-05-07 19:53:10 |
合計ジャッジ時間 | 34,228 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,072 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 24 ms
5,376 KB |
testcase_05 | AC | 27 ms
5,376 KB |
testcase_06 | AC | 3 ms
5,376 KB |
testcase_07 | AC | 457 ms
5,376 KB |
testcase_08 | AC | 39 ms
5,376 KB |
testcase_09 | AC | 22 ms
5,376 KB |
testcase_10 | AC | 61 ms
5,376 KB |
testcase_11 | AC | 54 ms
5,376 KB |
testcase_12 | AC | 1 ms
5,376 KB |
testcase_13 | AC | 88 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 12 ms
5,376 KB |
testcase_16 | AC | 166 ms
5,376 KB |
testcase_17 | AC | 333 ms
5,376 KB |
testcase_18 | AC | 324 ms
5,376 KB |
testcase_19 | AC | 1,115 ms
5,376 KB |
testcase_20 | AC | 2,107 ms
5,376 KB |
testcase_21 | AC | 1,084 ms
5,376 KB |
testcase_22 | AC | 535 ms
5,376 KB |
testcase_23 | AC | 508 ms
5,376 KB |
testcase_24 | AC | 562 ms
5,376 KB |
testcase_25 | AC | 522 ms
5,376 KB |
testcase_26 | AC | 2,035 ms
5,376 KB |
testcase_27 | AC | 1,597 ms
5,376 KB |
testcase_28 | AC | 2,345 ms
5,376 KB |
testcase_29 | AC | 329 ms
5,376 KB |
testcase_30 | AC | 322 ms
5,376 KB |
testcase_31 | AC | 332 ms
5,376 KB |
testcase_32 | AC | 335 ms
5,376 KB |
testcase_33 | AC | 624 ms
5,376 KB |
testcase_34 | AC | 613 ms
5,376 KB |
testcase_35 | AC | 2,412 ms
5,376 KB |
testcase_36 | AC | 2,420 ms
5,376 KB |
testcase_37 | AC | 2,395 ms
5,376 KB |
testcase_38 | AC | 2,534 ms
5,376 KB |
testcase_39 | AC | 2 ms
5,376 KB |
testcase_40 | AC | 12 ms
5,376 KB |
testcase_41 | AC | 2 ms
5,376 KB |
testcase_42 | AC | 3 ms
5,376 KB |
testcase_43 | AC | 6 ms
5,376 KB |
testcase_44 | AC | 20 ms
5,376 KB |
testcase_45 | AC | 3 ms
5,376 KB |
testcase_46 | AC | 15 ms
5,376 KB |
testcase_47 | AC | 532 ms
5,376 KB |
testcase_48 | AC | 516 ms
5,376 KB |
testcase_49 | AC | 583 ms
5,376 KB |
testcase_50 | AC | 524 ms
5,376 KB |
testcase_51 | AC | 453 ms
5,376 KB |
testcase_52 | AC | 291 ms
5,376 KB |
testcase_53 | AC | 450 ms
5,376 KB |
testcase_54 | AC | 12 ms
5,376 KB |
testcase_55 | AC | 2 ms
5,376 KB |
testcase_56 | AC | 1 ms
5,376 KB |
testcase_57 | AC | 1 ms
5,376 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long long LL; LL getPlaced(vector<LL>& a, LL begin, LL end, LL place){ LL pivot = a[(begin+end)/2]; LL large = 0; LL same = 0; for(LL i = begin; i < end-large; ){ if(a[i] > pivot){ swap(a[end-1-large], a[i]); ++large; }else if(a[i] == pivot){ swap(a[begin+same], a[i]); ++same; ++i; }else{ ++i; } } //cerr << "debug " << begin << ", " << end << ", " << place << ", " << same << ", " << large << endl; LL n = end - begin; if(place < n - same - large){ return getPlaced(a, begin+same, end-large, place); }else if(place < n - large){ return pivot; }else{ return getPlaced(a, end-large, end, place - (n-large)); } } LL getMedian(vector<LL>& a, LL begin, LL end){ LL n = end - begin; return getPlaced(a, begin, end, (n-1)/2); } void build(vector<LL>& a, LL n, LL k, vector<LL>& left, vector<LL>& left_cum){ for(LL i = 0; (i+1)*k <= n; ++i){ left[i] = getMedian(a, i*k, (i+1)*k); } LL cur = 0; for(LL i = 0; i < left.size(); ++i){ cur += left[i]; left_cum[i+1] = max(cur, left_cum[i]); } } LL solve(vector<LL> a, LL n, LL k){ vector<LL> b = a; reverse(b.begin(), b.end()); vector<LL> left(n / k); vector<LL> right(n / k); vector<LL> left_cum(n / k + 1); vector<LL> right_cum(n / k + 1); build(a, n, k, left, left_cum); build(b, n, k, right, right_cum); LL ans = 0; for(LL i = 0; i < left_cum.size(); ++i){ ans = max(ans, left_cum[i] + right_cum[right_cum.size()-1-i]); } /* cerr << "k=" << k << endl; for(LL i = 0; i < left_cum.size(); ++i){ cerr << "left " << left_cum[i] << endl; } for(LL i = 0; i < left_cum.size(); ++i){ cerr << "right " << right_cum[i] << endl; } cerr << "best=" << ans * k << endl; */ return ans * k; } int main(){ LL N; cin >> N; vector<LL> a(N); for(LL i = 0; i < N; ++i){ cin >> a[i]; } LL ans = 0; for(LL k = 1; k <= N; ++k){ ans = max(ans, solve(a, N, k)); } cout << ans << endl; }