結果

問題 No.2488 Mod Sum Maximization
ユーザー binapbinap
提出日時 2023-09-29 22:49:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 698 bytes
コンパイル時間 3,480 ms
コンパイル使用メモリ 226,212 KB
実行使用メモリ 5,692 KB
最終ジャッジ日時 2023-09-29 22:50:04
合計ジャッジ時間 6,993 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 98 ms
5,332 KB
testcase_05 WA -
testcase_06 AC 94 ms
5,068 KB
testcase_07 WA -
testcase_08 AC 95 ms
5,268 KB
testcase_09 AC 73 ms
4,888 KB
testcase_10 WA -
testcase_11 AC 4 ms
4,380 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 61 ms
4,504 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 82 ms
4,896 KB
testcase_20 AC 91 ms
5,208 KB
testcase_21 AC 86 ms
4,892 KB
testcase_22 AC 96 ms
5,316 KB
testcase_23 AC 100 ms
5,576 KB
testcase_24 WA -
testcase_25 AC 3 ms
4,380 KB
testcase_26 WA -
testcase_27 AC 51 ms
4,376 KB
testcase_28 AC 53 ms
4,380 KB
testcase_29 AC 51 ms
4,380 KB
testcase_30 AC 34 ms
4,380 KB
testcase_31 AC 8 ms
4,380 KB
testcase_32 AC 81 ms
5,004 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 97 ms
5,208 KB
testcase_35 AC 32 ms
4,380 KB
testcase_36 AC 1 ms
4,376 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 1 ms
4,380 KB
testcase_40 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long>> vvl;
typedef pair<int,int> P;
typedef long double ld;

int main(){
	int n;
	cin >> n;
	vl a(n);
	rep(i, n) cin >> a[i];
	ll base = 0;
	rep(i, n) base += a[i] % a[(i + 1) % n];
	ll ans = base;
	for(int i = 0; i < n - 1; i++){
		ll tmp = base;
		tmp -= a[i] % a[(i + 1) % n];
		tmp -= a[n - 1] % a[0];
		tmp += a[n - 1] % a[i];
		tmp += a[i] % a[0];
		ans = max(tmp, ans);
//		cout << tmp << "\n";
	}
	cout << ans;
	return 0;
}
0