結果

問題 No.10 +か×か
ユーザー CleyLCleyL
提出日時 2020-01-21 20:33:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 722 bytes
コンパイル時間 723 ms
コンパイル使用メモリ 78,372 KB
実行使用メモリ 814,768 KB
最終ジャッジ日時 2023-09-20 09:08:31
合計ジャッジ時間 5,388 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 MLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
int n,z;
int a[50];
struct dta{
  string A;
  int nw;
};
int main(){
    cin>>n>>z;
    for(int i = 0; n > i; i++){
        cin>>a[i];
    }
    queue<dta> Z;
    Z.push({"",a[0]});
    while(!Z.empty()){
      dta T = Z.front();Z.pop();
      //cout << T.A << " " << T.nw << endl;
      if(T.A.size() == n-1 && T.nw == z){
        cout << T.A << endl;
        return 0;
      }else if(T.A.size() == n-1){
        continue;
      }
      if(T.nw+a[T.A.size()+1] <= z){
        Z.push({T.A+"+",T.nw+a[T.A.size()+1]});
      }
      if(T.nw*a[T.A.size()+1] <= z){
        Z.push({T.A+"*",T.nw*a[T.A.size()+1]});
      }
    }
}
0