結果

問題 No.919 You Are A Project Manager
ユーザー ningenMe
提出日時 2019-10-25 08:27:27
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,314 bytes
コンパイル時間 1,789 ms
コンパイル使用メモリ 176,080 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 03:56:01
合計ジャッジ時間 44,714 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 7 WA * 48
権限があれば一括ダウンロードができます

ソースコード

diff #

#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];

	if(N==1){
		cout << max(A[0],0) << endl;
		return 0;
	}

	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 <= 5000; ++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;
}
0