結果

問題 No.2488 Mod Sum Maximization
ユーザー 沙耶花沙耶花
提出日時 2023-09-29 22:09:20
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 620 bytes
コンパイル時間 5,271 ms
コンパイル使用メモリ 262,008 KB
実行使用メモリ 5,584 KB
最終ジャッジ日時 2023-09-29 22:09:35
合計ジャッジ時間 7,672 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 AC 1 ms
4,356 KB
testcase_02 AC 1 ms
4,360 KB
testcase_03 WA -
testcase_04 AC 100 ms
5,488 KB
testcase_05 WA -
testcase_06 AC 94 ms
5,332 KB
testcase_07 WA -
testcase_08 AC 96 ms
5,212 KB
testcase_09 AC 73 ms
5,016 KB
testcase_10 WA -
testcase_11 AC 4 ms
4,356 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 53 ms
4,488 KB
testcase_16 AC 4 ms
4,356 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 74 ms
5,020 KB
testcase_20 AC 82 ms
5,308 KB
testcase_21 AC 77 ms
4,892 KB
testcase_22 AC 86 ms
5,484 KB
testcase_23 AC 88 ms
5,492 KB
testcase_24 WA -
testcase_25 AC 4 ms
4,356 KB
testcase_26 WA -
testcase_27 AC 51 ms
4,356 KB
testcase_28 AC 52 ms
4,508 KB
testcase_29 AC 48 ms
4,376 KB
testcase_30 AC 30 ms
4,356 KB
testcase_31 AC 7 ms
4,356 KB
testcase_32 AC 74 ms
4,932 KB
testcase_33 AC 2 ms
4,356 KB
testcase_34 AC 89 ms
5,160 KB
testcase_35 AC 29 ms
4,356 KB
testcase_36 AC 2 ms
4,356 KB
testcase_37 AC 1 ms
4,356 KB
testcase_38 AC 2 ms
4,352 KB
testcase_39 AC 1 ms
4,352 KB
testcase_40 AC 1 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001

int main(){
	
	int n;
	cin>>n;
	vector<long long> a(n);
	rep(i,n){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	long long ans = 0;
	rep(i,n-1)ans += a[i];
	ans += a[n-1]%a[0];
	
	long long ma = ans;
	for(int i=1;i<n-1;i++){
		long long t = ans;
		t -= a[i];
		t -= a[n-1]%a[0];
		t += a[n-1]%a[i];
		t += a[i]%a[0];
		ma = max(ma,t);
		
	}
	cout<<ma<<endl;
	
	return 0;
}
0