結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
Bantako
|
| 提出日時 | 2017-06-24 11:34:18 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 358 bytes |
| コンパイル時間 | 437 ms |
| コンパイル使用メモリ | 37,068 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-04 02:42:47 |
| 合計ジャッジ時間 | 1,357 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 WA * 10 |
コンパイルメッセージ
main.cpp:4:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
4 | 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%d",&L,&N);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | scanf("%d",&W[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include<stdio.h>
#include<algorithm>
using namespace std;
main(){
int L,N;
int W[10000];
scanf("%d%d",&L,&N);
for(int i = 0;i < N;i++){
scanf("%d",&W[i]);
}
sort(W,W+N);
int sum = 0;
for(int i = 0;i < N;i++){
sum += W[i];
if(sum > L){
printf("%d\n",i);
break;
}
}
}
Bantako