結果
| 問題 |
No.5 数字のブロック
|
| ユーザー |
nanatutmc
|
| 提出日時 | 2019-09-20 01:06:50 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 310 ms / 5,000 ms |
| コード長 | 736 bytes |
| コンパイル時間 | 229 ms |
| コンパイル使用メモリ | 29,952 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-22 10:09:23 |
| 合計ジャッジ時間 | 3,640 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 34 |
コンパイルメッセージ
main.c:3:1: warning: return type defaults to 'int' [-Wimplicit-int]
3 | main() {
| ^~~~
ソースコード
#include <stdio.h>
main() {
int L, N;
int width[10000];
scanf("%d", &L);
scanf("%d", &N);
for (int i=0; i<N; i++) {
scanf("%d", &(width[i]));
}
// sort
while (1) {
int flag = 0;
for (int i=0; i<N-1; i++) {
if (width[i] > width[i+1]) {
int tmp = width[i];
width[i] = width[i+1];
width[i+1] = tmp;
flag = 1;
}
}
if (flag == 0)
break;
}
int total = 0;
for (int i = 0; i<N; i++) {
total += width[i];
if (total > L) {
printf("%d\n", i);
return 0;
}
}
printf("%d\n", N);
}
nanatutmc