結果

問題 No.937 Ultra Sword
ユーザー yakkiyakki
提出日時 2019-11-29 23:38:06
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,308 bytes
コンパイル時間 794 ms
コンパイル使用メモリ 93,644 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-01 02:54:56
合計ジャッジ時間 3,166 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
int main(){
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    sort(A.begin(),A.end());
    vector<ll> sum(N+1);
    for(int i = N; i >= 1; i--){
        sum[i-1] = sum[i] +A[i-1];
    }
    int k = 0;
    ll a = LINF;
    int ans = 0;
    for(int i = N-1; i >= 0; i--){
        k = GCD(k,A[i]);
        if(a > sum[i]/k+sum[0]-sum[i-1]){
            a = sum[i]/k+sum[0]-sum[i-1];
            ans = k;
        }
        //cout << a << endl;
    }
    rep(i,N){
        if(A[i] % ans == 0) A[i] /= ans;
    }
    ll m = 0;
    rep(i,N){
        m += A[i];
    }
    cout << m << endl;
}
0