結果
問題 |
No.4 おもりと天秤
|
ユーザー |
![]() |
提出日時 | 2017-07-12 21:25:45 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 496 bytes |
コンパイル時間 | 141 ms |
コンパイル使用メモリ | 22,784 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-26 10:21:02 |
合計ジャッジ時間 | 832 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type] 6 | main(){ | ^~~~ main.cpp: In function ‘int main()’: main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | scanf("%d",&N); | ~~~~~^~~~~~~~~ main.cpp:10:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | scanf("%d",&W[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include<stdio.h> int N; int W[100]; int dp[101][10001]; int search(int i,int w); main(){ scanf("%d",&N); int sum = 0; for(int i = 0;i < N;i++){ scanf("%d",&W[i]); sum += W[i]; } dp[0][0] = 1; for(int i = 1;i <= N;i++){ for(int j = 0;j < sum+1;j++){ if(dp[i-1][j]){ dp[i][j]++; dp[i][j+W[i-1]]++; } } } printf("%s\n",sum%2?"impossible":dp[N][sum/2]?"possible":"impossible"); }