Submission #72537420
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6+6;
int n,k,x;
int a[N];
signed main(){
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin>>n>>k>>x;
for(int i=1;i<=n;i++)cin>>a[i];
sort(a+1,a+n+1);
int tmp=0,cnt=0;bool flag=false;
for(int i=k;i>=1;i--){
tmp+=a[i],cnt++;
if(tmp>=x){
flag=true;
break;
}
}
if(!flag)cout<<-1;
else cout<<n-k+cnt;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Sake or Water |
| User | kac17 |
| Language | C++23 (GCC 15.2.0) |
| Score | 300 |
| Code Size | 441 Byte |
| Status | AC |
| Exec Time | 34 ms |
| Memory | 6068 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| 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 |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| example_00.txt | AC | 1 ms | 3504 KiB |
| example_01.txt | AC | 1 ms | 3476 KiB |
| example_02.txt | AC | 1 ms | 3488 KiB |
| hand_00.txt | AC | 17 ms | 5980 KiB |
| hand_01.txt | AC | 17 ms | 5864 KiB |
| hand_02.txt | AC | 33 ms | 5996 KiB |
| hand_03.txt | AC | 32 ms | 6036 KiB |
| hand_04.txt | AC | 33 ms | 6036 KiB |
| hand_05.txt | AC | 33 ms | 5976 KiB |
| hand_06.txt | AC | 32 ms | 5980 KiB |
| hand_07.txt | AC | 1 ms | 3432 KiB |
| hand_08.txt | AC | 1 ms | 3484 KiB |
| hand_09.txt | AC | 1 ms | 3584 KiB |
| hand_10.txt | AC | 1 ms | 3536 KiB |
| hand_11.txt | AC | 17 ms | 5996 KiB |
| random_00.txt | AC | 34 ms | 5980 KiB |
| random_01.txt | AC | 34 ms | 5980 KiB |
| random_02.txt | AC | 34 ms | 6036 KiB |
| random_03.txt | AC | 34 ms | 5908 KiB |
| random_04.txt | AC | 34 ms | 6036 KiB |
| random_05.txt | AC | 34 ms | 5980 KiB |
| random_06.txt | AC | 34 ms | 5984 KiB |
| random_07.txt | AC | 34 ms | 5976 KiB |
| random_08.txt | AC | 34 ms | 5976 KiB |
| random_09.txt | AC | 34 ms | 5980 KiB |
| random_10.txt | AC | 33 ms | 6068 KiB |
| random_11.txt | AC | 34 ms | 5864 KiB |
| random_12.txt | AC | 34 ms | 6064 KiB |
| random_13.txt | AC | 34 ms | 5832 KiB |
| random_14.txt | AC | 34 ms | 5976 KiB |
| random_15.txt | AC | 33 ms | 5980 KiB |
| random_16.txt | AC | 34 ms | 5916 KiB |
| random_17.txt | AC | 34 ms | 6008 KiB |