結果
問題 | No.2488 Mod Sum Maximization |
ユーザー |
👑 |
提出日時 | 2023-09-29 22:49:57 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 698 bytes |
コンパイル時間 | 3,951 ms |
コンパイル使用メモリ | 228,460 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-22 16:47:37 |
合計ジャッジ時間 | 6,325 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 WA * 11 |
ソースコード
#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;}