結果

問題 No.1334 Multiply or Add
ユーザー penguinmanpenguinman
提出日時 2020-11-04 03:39:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,135 bytes
コンパイル時間 1,485 ms
コンパイル使用メモリ 170,632 KB
実行使用メモリ 4,780 KB
最終ジャッジ日時 2023-09-29 21:22:57
合計ジャッジ時間 6,126 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 34 ms
4,780 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 33 ms
4,728 KB
testcase_07 AC 33 ms
4,464 KB
testcase_08 WA -
testcase_09 AC 33 ms
4,456 KB
testcase_10 AC 33 ms
4,532 KB
testcase_11 AC 33 ms
4,660 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 33 ms
4,668 KB
testcase_17 AC 33 ms
4,460 KB
testcase_18 AC 33 ms
4,660 KB
testcase_19 AC 33 ms
4,608 KB
testcase_20 AC 33 ms
4,540 KB
testcase_21 AC 33 ms
4,500 KB
testcase_22 AC 32 ms
4,664 KB
testcase_23 AC 33 ms
4,660 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 33 ms
4,668 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 33 ms
4,660 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 1 ms
4,376 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 AC 91 ms
4,544 KB
testcase_51 AC 92 ms
4,720 KB
testcase_52 AC 91 ms
4,720 KB
testcase_53 AC 91 ms
4,580 KB
testcase_54 AC 92 ms
4,600 KB
testcase_55 AC 84 ms
4,668 KB
testcase_56 AC 1 ms
4,376 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 AC 1 ms
4,376 KB
testcase_60 AC 2 ms
4,376 KB
testcase_61 AC 1 ms
4,376 KB
testcase_62 AC 2 ms
4,376 KB
testcase_63 AC 1 ms
4,376 KB
testcase_64 AC 1 ms
4,384 KB
testcase_65 AC 2 ms
4,376 KB
testcase_66 AC 75 ms
4,380 KB
testcase_67 AC 49 ms
4,376 KB
testcase_68 AC 4 ms
4,380 KB
testcase_69 AC 85 ms
4,376 KB
testcase_70 AC 80 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];
    cout<<ans<<endl;
}
0