結果

問題 No.2488 Mod Sum Maximization
ユーザー 03吳柏翰03吳柏翰
提出日時 2023-10-30 05:54:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,291 bytes
コンパイル時間 1,762 ms
コンパイル使用メモリ 172,484 KB
実行使用メモリ 54,112 KB
最終ジャッジ日時 2023-10-30 05:54:16
合計ジャッジ時間 6,018 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
30,152 KB
testcase_01 AC 11 ms
30,152 KB
testcase_02 AC 12 ms
34,284 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます

ソースコード

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
#define F first
#define S second
#define pb push_back
int n,a[1000005],ans[1000005];
vector<int> v[1000005];
int mn,cnt[2000005];
signed main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin>>n;
    int sum=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    mn=a[0];
    for(int i=0;i<n;i++)
    {
        int pos=0,now=a[i];
        while(now<=a[n-1])
        {
            while(a[pos]<now) pos++;
            v[pos].pb(i);
            now+=a[i];
        }

    }
    for(int i=0;i<n;i++)
    {
        //cout<<i<<endl;
        for(int j=0;j<v[i].size();j++)
        {
            //cout<<v[i-1][j]<<endl;
            if(ans[v[i][j]]<1e17&&v[i][j]!=i)
            {
                cnt[ans[v[i][j]]]--;
                ans[v[i][j]]+=a[v[i][j]];
                cnt[ans[v[i][j]]]++;
                while(cnt[mn]==0) mn++;
            }
        }
        //cout<<"rkv"<<endl;
        if(i!=0) ans[i]=mn;
        ans[i]+=a[i];
        cnt[ans[i]]++;
        //cout<<ans[i]<<endl;

    }
    cout<<sum-ans[n-1]+a[n-1]<<'\n';








}
0