結果
問題 | No.919 You Are A Project Manager |
ユーザー | QCFium |
提出日時 | 2019-11-01 17:28:31 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 2,937 bytes |
コンパイル時間 | 1,803 ms |
コンパイル使用メモリ | 177,248 KB |
実行使用メモリ | 14,616 KB |
最終ジャッジ日時 | 2023-10-13 00:53:03 |
合計ジャッジ時間 | 11,412 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | -- | - |
testcase_02 | -- | - |
testcase_03 | -- | - |
testcase_04 | -- | - |
testcase_05 | -- | - |
testcase_06 | -- | - |
testcase_07 | -- | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
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 | -- | - |
ソースコード
#include <bits/stdc++.h> int ri() { int n; scanf("%d", &n); return n; } // dummy one struct AVL { std::vector<int> data; void insert(int n) { data.push_back(n); std::sort(data.begin(), data.end()); } void remove(int n) { auto itr = std::find(data.begin(), data.end(), n); assert(itr != data.end()); data.erase(itr); } int operator [] (int i) { return data[i]; } size_t size() { return data.size(); } }; int main() { int n = ri(); int a[n]; for (int i = 0; i < n; i++) a[i] = ri(); std::vector<int64_t> median_left[n + 1]; std::vector<int64_t> median_right[n + 1]; for (int i = 0; i <= n; i++) { median_left[i].resize(n / (i + 1)); median_right[i].resize(n / (i + 1)); } int sq = sqrt(n); for (int i = 0; i < sq; i++) { { int head = 0; int tail = 0; AVL set; for (int j = 0; i < (int) median_left[j].size(); j++) { // j + 1 while (head < (j + 1) * (i + 1)) set.insert(a[head++]); while (tail < (j + 1) * i) set.remove(a[tail++]); assert(set.size()); median_left[j][i] = set[(set.size() - 1) / 2]; } } { int head = n - 1; int tail = n - 1; AVL set; for (int j = 0; i < (int) median_left[j].size(); j++) { // j + 1 while (head >= n - (j + 1) * (i + 1)) set.insert(a[head--]); while (tail >= n - (j + 1) * i) set.remove(a[tail--]); assert(set.size()); median_right[j][i] = set[(set.size() - 1) / 2]; } } } for (int i = 0; i <= n; i++) { for (int j = sq; j < (int) median_left[i].size(); j++) { std::vector<int> sorted; for (int k = j * (i + 1); k < (j + 1) * (i + 1); k++) sorted.push_back(a[k]); std::sort(sorted.begin(), sorted.end()); median_left[i][j] = sorted[(sorted.size() - 1) / 2]; } for (int j = sq; j < (int) median_right[i].size(); j++) { std::vector<int> sorted; for (int k = n - (j + 1) * (i + 1); k < n - j * (i + 1); k++) sorted.push_back(a[k]); std::sort(sorted.begin(), sorted.end()); median_right[i][j] = sorted[(sorted.size() - 1) / 2]; } } int64_t res = 0; for (int i = 0; i < n; i++) { int max_index_sum = (int) median_left[i].size() - 2; for (int j = 0; j + 1 < (int) median_left[i].size(); j++) median_left[i][j + 1] += median_left[i][j]; for (int j = 0; j + 1 < (int) median_left[i].size(); j++) median_left[i][j + 1] = std::max(median_left[i][j + 1], median_left[i][j]); for (int j = 0; j + 1 < (int) median_right[i].size(); j++) median_right[i][j + 1] += median_right[i][j]; for (int j = 0; j + 1 < (int) median_right[i].size(); j++) median_right[i][j + 1] = std::max(median_right[i][j + 1], median_right[i][j]); int64_t cur = 0; for (int j = 0; j + 1 < (int) median_left[i].size(); j++) cur = std::max(cur, median_left[i][j] + median_right[i][max_index_sum - j]); cur = std::max(cur, median_left[i].back()); cur = std::max(cur, median_right[i].back()); res = std::max(res, cur * (i + 1)); } std::cout << res << std::endl; return 0; }