結果
| 問題 |
No.5 数字のブロック
|
| コンテスト | |
| ユーザー |
あ
|
| 提出日時 | 2015-10-26 16:20:16 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 455 bytes |
| コンパイル時間 | 1,307 ms |
| コンパイル使用メモリ | 158,488 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-13 11:38:21 |
| 合計ジャッジ時間 | 3,818 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 WA * 7 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
8 | scanf("%d",&L);
| ~~~~~^~~~~~~~~
main.cpp:9:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d",&N);
| ~~~~~^~~~~~~~~
main.cpp:15:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
15 | scanf("%d",&W[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
int L,N,ans=0;
scanf("%d",&L);
scanf("%d",&N);
int W[N];
for(int i=0;i<N;i++){
scanf("%d",&W[i]);
}
for(int i=0;i<N-1;i++){
for(int j=0;j<N-i-1;j++){
if(W[j]>W[j+1]){
int temp = W[j];
W[j] = W[j+1];
W[j+1] = temp;
}
}
}
for(int i=0;i<N;i++){
if(L-W[i]>0){
ans++;
L=L-W[i];
}
}
printf("%d\n",ans);
}
あ