結果
| 問題 |
No.4 おもりと天秤
|
| コンテスト | |
| ユーザー |
Irmystp
|
| 提出日時 | 2014-11-26 21:22:58 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 5,000 ms |
| コード長 | 669 bytes |
| コンパイル時間 | 1,208 ms |
| コンパイル使用メモリ | 157,976 KB |
| 実行使用メモリ | 11,412 KB |
| 最終ジャッジ日時 | 2024-06-26 09:04:18 |
| 合計ジャッジ時間 | 2,034 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 23 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
10 | scanf("%d", &N);
| ~~~~~^~~~~~~~~~
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
12 | scanf("%d", w+x);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
int N;
int w[100];
int arr[101][20001];
int* dp[101];
int main(){
scanf("%d", &N);
for(int x = 0; x < N; x++){
scanf("%d", w+x);
fill(arr[x], arr[x]+20001, 0);
dp[x] = arr[x] + 10000;
}
dp[N] = arr[N] + 10000;
dp[0][0] = 1;
for(int x = 0; x < N; x++){
for(int y = -10000; y <= 10000; y++){
if(dp[x][y]){
dp[x + 1][y + w[x]] = 1;
dp[x + 1][y - w[x]] = 1;
}
}
}
if(dp[N][0]){
puts("possible");
}else{
puts("impossible");
}
return 0;
}
Irmystp