結果
| 問題 |
No.919 You Are A Project Manager
|
| ユーザー |
|
| 提出日時 | 2019-10-25 08:25:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,258 bytes |
| コンパイル時間 | 4,081 ms |
| コンパイル使用メモリ | 176,936 KB |
| 実行使用メモリ | 17,208 KB |
| 最終ジャッジ日時 | 2024-07-19 03:51:19 |
| 合計ジャッジ時間 | 11,034 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | TLE * 1 -- * 54 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
template <class T> inline void chmax(T& a, const T b){a=max(a,b);}
int main() {
int N; cin >> N;
vector<int> A(N);
for(int i = 0; i < N; ++i) cin >> A[i];
random_device rnd; // 非決定的な乱数生成器を生成
mt19937 mt(rnd()); // メルセンヌ・ツイスタの32ビット版、引数は初期シード値
uniform_int_distribution<> randK(1, N); // [0, 99] 範囲の一様乱数
uniform_int_distribution<> randL(1, N/2); // [0, 99] 範囲の一様乱数
uniform_int_distribution<> randR(1, N/2); // [0, 99] 範囲の一様乱数
long long ans = 0;
for(int n = 0; n <= 500000; ++n){
int K = randK(mt);
int L = randL(mt);
int R = randR(mt);
long long sum = 0;
for(int i = 1; i <= L; ++i) {
vector<long long> B;
for(int j = K*(i-1); j < K*i && K*i <= N; ++j) {
B.push_back(A[j]);
}
sort(B.begin(),B.end());
if(B.size()) sum += B[K/2];
}
for(int i = 1; i <= R; ++i) {
vector<long long> B;
for(int j = N-1 - K*(i-1); N-1 - K*i < j && K*L <= N-1 - K*i; --j) {
B.push_back(A[j]);
}
sort(B.begin(),B.end());
if(B.size()) sum += B[K/2];
}
chmax(ans,sum);
}
cout << ans << endl;
return 0;
}