結果
| 問題 |
No.10 +か×か
|
| コンテスト | |
| ユーザー |
y_mazun
|
| 提出日時 | 2015-04-17 03:13:21 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 12 ms / 5,000 ms |
| コード長 | 771 bytes |
| コンパイル時間 | 814 ms |
| コンパイル使用メモリ | 64,424 KB |
| 実行使用メモリ | 6,016 KB |
| 最終ジャッジ日時 | 2024-12-14 15:29:31 |
| 合計ジャッジ時間 | 1,272 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 12 |
コンパイルメッセージ
main.cpp: In function ‘int getInt()’:
main.cpp:6:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
6 | inline int getInt(){ int s; scanf("%d", &s); return s; }
| ~~~~~^~~~~~~~~~
ソースコード
#include <iostream>
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#include <queue>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }
#include <set>
using namespace std;
int dp[51][100000];
int main(){
const int n = getInt();
const int t = getInt();
vector<int> a(n);
REP(i,n) a[i] = getInt();
dp[n][t] = 1;
for(int i = n - 1; i >= 0; i--){
REP(j,t+1) if(dp[i + 1][j]){
if(j - a[i] >= 0)
dp[i][j - a[i]] = 1;
if(j % a[i] == 0)
dp[i][j / a[i]] = 1;
}
}
string ans(n - 1, '*');
int cur = a[0];
REP(i,n-1){
if(dp[i + 2][cur + a[i + 1]]){
cur += a[i + 1];
ans[i] = '+';
}else{
cur *= a[i + 1];
ans[i] = '*';
}
}
puts(ans.c_str());
return 0;
}
y_mazun