結果
| 問題 |
No.2424 Josouzai
|
| コンテスト | |
| ユーザー |
chro_96
|
| 提出日時 | 2023-08-18 21:32:50 |
| 言語 | C (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 55 ms / 2,000 ms |
| コード長 | 595 bytes |
| コンパイル時間 | 191 ms |
| コンパイル使用メモリ | 29,568 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-28 05:52:20 |
| 合計ジャッジ時間 | 2,174 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 33 |
ソースコード
#include <stdio.h>
#include <stdlib.h>
int cmp_int (const void *ap, const void *bp) {
int a = *(int *)ap;
int b = *(int *)bp;
if (a < b) {
return -1;
}
if (a > b) {
return 1;
}
return 0;
}
int main () {
int n = 0;
int k = 0;
int a[200000] = {};
int res = 0;
int ans = 0;
res = scanf("%d", &n);
res = scanf("%d", &k);
for (int i = 0; i < n; i++) {
res = scanf("%d", a+i);
}
qsort(a, n, sizeof(int), cmp_int);
for (int i = 0; i < n; i++) {
if (a[i] <= k) {
ans++;
k -= a[i];
}
}
printf("%d %d\n", ans, k);
return 0;
}
chro_96