結果
問題 |
No.5 数字のブロック
|
ユーザー |
|
提出日時 | 2024-05-18 20:48:24 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 110 ms / 5,000 ms |
コード長 | 764 bytes |
コンパイル時間 | 339 ms |
コンパイル使用メモリ | 29,568 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-12-20 16:33:06 |
合計ジャッジ時間 | 2,476 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <stdio.h> #include <stdlib.h> #include "string.h" void func5(void) { int total = 0; int n = 0; int t = 0; int r = 0; int *array = NULL; scanf("%d", &total); scanf("%d", &n); array = malloc(n * sizeof(int)); memset(array, 0, n * sizeof(int)); for (int i = 0; i < n; i++) { scanf("%d", &t); for (int j = 0; j < i; j++) { if (t < array[j]) { int tmp = array[j]; array[j] = t; t = tmp; } } array[i] = t; } for (int i = 0; i < n; ++i) { if (total < array[i]) break; total -= array[i]; r++; } printf("%d\n", r); } int main(void) { func5(); return 0; }