結果

問題 No.1334 Multiply or Add
ユーザー penguinmanpenguinman
提出日時 2020-11-04 03:38:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,148 bytes
コンパイル時間 1,365 ms
コンパイル使用メモリ 169,632 KB
実行使用メモリ 4,796 KB
最終ジャッジ日時 2023-09-29 21:22:43
合計ジャッジ時間 5,362 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 AC 26 ms
4,572 KB
testcase_05 AC 26 ms
4,796 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 27 ms
4,560 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 27 ms
4,660 KB
testcase_13 AC 28 ms
4,540 KB
testcase_14 AC 28 ms
4,528 KB
testcase_15 AC 26 ms
4,636 KB
testcase_16 AC 28 ms
4,596 KB
testcase_17 AC 27 ms
4,568 KB
testcase_18 AC 28 ms
4,636 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 27 ms
4,532 KB
testcase_23 WA -
testcase_24 AC 28 ms
4,624 KB
testcase_25 AC 27 ms
4,624 KB
testcase_26 AC 27 ms
4,572 KB
testcase_27 AC 27 ms
4,660 KB
testcase_28 AC 27 ms
4,640 KB
testcase_29 WA -
testcase_30 AC 29 ms
4,624 KB
testcase_31 AC 27 ms
4,596 KB
testcase_32 WA -
testcase_33 AC 27 ms
4,636 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 27 ms
4,572 KB
testcase_39 AC 1 ms
4,376 KB
testcase_40 AC 11 ms
4,380 KB
testcase_41 AC 4 ms
4,380 KB
testcase_42 AC 5 ms
4,380 KB
testcase_43 AC 21 ms
4,380 KB
testcase_44 AC 12 ms
4,380 KB
testcase_45 AC 6 ms
4,380 KB
testcase_46 AC 15 ms
4,380 KB
testcase_47 AC 20 ms
4,376 KB
testcase_48 AC 15 ms
4,376 KB
testcase_49 AC 28 ms
4,528 KB
testcase_50 AC 79 ms
4,564 KB
testcase_51 AC 79 ms
4,756 KB
testcase_52 AC 79 ms
4,568 KB
testcase_53 AC 79 ms
4,596 KB
testcase_54 AC 78 ms
4,588 KB
testcase_55 AC 72 ms
4,624 KB
testcase_56 AC 2 ms
4,380 KB
testcase_57 AC 2 ms
4,380 KB
testcase_58 AC 2 ms
4,380 KB
testcase_59 AC 1 ms
4,376 KB
testcase_60 AC 1 ms
4,376 KB
testcase_61 WA -
testcase_62 AC 1 ms
4,376 KB
testcase_63 AC 1 ms
4,380 KB
testcase_64 AC 2 ms
4,376 KB
testcase_65 AC 1 ms
4,376 KB
testcase_66 AC 65 ms
4,376 KB
testcase_67 AC 42 ms
4,380 KB
testcase_68 AC 3 ms
4,376 KB
testcase_69 AC 72 ms
4,380 KB
testcase_70 AC 69 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::vector;
using ll=long long;
const int mod=1e9+7;
int main(){
    int N; cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    {
        vector<int> B=A;
        sort(B.begin(),B.end());
        if(B[N-1]==1){
            cout<<N<<endl;
            return 0;
        }
    }
    ll ans=1;
    for(int i=0;i<N;i++){
        ans*=A[i];
        if(ans>=2*N) break;
    }
    if(ans>=2*N){
        ans=1;
        for(int i=0;i<N;i++){
            ans*=A[i];
            ans%=mod;
        }
        for(int i=0;i<N;i++){
            if(A[i]>1) break;
            ans++;
        }
        for(int i=N-1;i>=0;i--){
            if(A[i]>1) break;
            ans++;
        }
        ans%=mod;
        cout<<ans<<endl;
        return 0;
    }
    ans=1;
    for(int i=0;i<N;i++){
        ans*=A[i];
        ans%=mod;
    }
    for(int i=0;i<N;i++){
        if(A[i]>1) break;
        ans++;
    }
    for(int i=N-1;i>=0;i--){
        if(A[i]>1) break;
        ans++;
    }
    ll sum=0;
    for(int i=0;i<N;i++) sum+=A[i];
    ans=sum;
    cout<<ans<<endl;
}
0