提出 #72507531
ソースコード 拡げる
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define pb push_back
#define si(x) int(x.size())
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const int N = 300000;
int a[N+5];
int main(){
ios_base::sync_with_stdio(false), cin.tie(0);
cout.precision(10);
cout << fixed;
int n, k;
ll x;
cin >> n >> k >> x;
for(int i=1; i<=n; i++){
cin >> a[i];
}
sort(a+1, a+1+n);
ll sum = 0;
int cnt = n - k;
for(int i=k; i>=1; i--){
sum += a[i];
cnt++;
if(sum >= x){
cout << cnt << "\n";
return 0;
}
}
cout << "-1\n";
return 0;
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - Sake or Water |
| ユーザ | JovanB |
| 言語 | C++23 (GCC 15.2.0) |
| 得点 | 300 |
| コード長 | 751 Byte |
| 結果 | AC |
| 実行時間 | 31 ms |
| メモリ | 4996 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | example_00.txt, example_01.txt, example_02.txt |
| All | example_00.txt, example_01.txt, example_02.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| example_00.txt | AC | 1 ms | 3556 KiB |
| example_01.txt | AC | 1 ms | 3472 KiB |
| example_02.txt | AC | 1 ms | 3448 KiB |
| hand_00.txt | AC | 15 ms | 4940 KiB |
| hand_01.txt | AC | 15 ms | 4836 KiB |
| hand_02.txt | AC | 28 ms | 4764 KiB |
| hand_03.txt | AC | 29 ms | 4764 KiB |
| hand_04.txt | AC | 29 ms | 4852 KiB |
| hand_05.txt | AC | 29 ms | 4828 KiB |
| hand_06.txt | AC | 29 ms | 4792 KiB |
| hand_07.txt | AC | 1 ms | 3644 KiB |
| hand_08.txt | AC | 1 ms | 3560 KiB |
| hand_09.txt | AC | 1 ms | 3492 KiB |
| hand_10.txt | AC | 1 ms | 3560 KiB |
| hand_11.txt | AC | 15 ms | 4924 KiB |
| random_00.txt | AC | 30 ms | 4724 KiB |
| random_01.txt | AC | 30 ms | 4772 KiB |
| random_02.txt | AC | 30 ms | 4840 KiB |
| random_03.txt | AC | 30 ms | 4764 KiB |
| random_04.txt | AC | 30 ms | 4776 KiB |
| random_05.txt | AC | 29 ms | 4840 KiB |
| random_06.txt | AC | 30 ms | 4724 KiB |
| random_07.txt | AC | 30 ms | 4836 KiB |
| random_08.txt | AC | 29 ms | 4996 KiB |
| random_09.txt | AC | 31 ms | 4772 KiB |
| random_10.txt | AC | 30 ms | 4836 KiB |
| random_11.txt | AC | 30 ms | 4840 KiB |
| random_12.txt | AC | 30 ms | 4752 KiB |
| random_13.txt | AC | 30 ms | 4940 KiB |
| random_14.txt | AC | 30 ms | 4840 KiB |
| random_15.txt | AC | 30 ms | 4776 KiB |
| random_16.txt | AC | 30 ms | 4776 KiB |
| random_17.txt | AC | 30 ms | 4916 KiB |