結果

問題 No.2488 Mod Sum Maximization
ユーザー 03吳柏翰03吳柏翰
提出日時 2023-10-29 20:07:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 833 bytes
コンパイル時間 2,395 ms
コンパイル使用メモリ 204,492 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2023-10-29 20:07:43
合計ジャッジ時間 5,093 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 WA -
testcase_04 AC 40 ms
5,888 KB
testcase_05 WA -
testcase_06 AC 37 ms
5,748 KB
testcase_07 WA -
testcase_08 AC 38 ms
5,796 KB
testcase_09 AC 29 ms
5,272 KB
testcase_10 WA -
testcase_11 AC 3 ms
4,348 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 24 ms
4,920 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 32 ms
5,428 KB
testcase_20 AC 34 ms
5,604 KB
testcase_21 AC 33 ms
5,524 KB
testcase_22 AC 37 ms
5,772 KB
testcase_23 AC 39 ms
5,840 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,348 KB
testcase_26 WA -
testcase_27 AC 20 ms
4,724 KB
testcase_28 AC 21 ms
4,752 KB
testcase_29 AC 20 ms
4,708 KB
testcase_30 AC 13 ms
4,348 KB
testcase_31 AC 4 ms
4,348 KB
testcase_32 AC 31 ms
5,396 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 37 ms
5,772 KB
testcase_35 AC 13 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 2 ms
4,348 KB
testcase_40 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
typedef long long ll;
#define F first
#define S second
#define pb emplace_back
int a[300005];
signed main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    if(n==2) cout<<a[0]+a[1]%a[0]<<'\n';
    else
    {
        int ans=a[n-1]%a[0];
        for(int i=0;i<n-1;i++) ans+=a[i];
        int sum=0,mn=1e18;
        for(int i=0;i<n;i++) sum+=a[i];
        for(int i=n-2;i>=1;i--)
        {
            mn=min(mn,a[i]-a[i]%a[0]);
            ans=max(ans,sum-mn-(a[n-1]-a[n-1]%a[i]));
        }

        cout<<ans<<'\n';

    }



}

0