Submission #72550211


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n, k, x;
  cin >> n >> k >> x;
  vector<long long> vec(n);
  long long count = 0;
  long long sake = 0;
  for(int i = 0; i < n; i++){
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  for(int i = 0; i < k; i++){
    sake += vec[i];
  }
  if(sake < x){
    cout << -1 << endl;
    return 0;
  }
  sake = 0;
  while(sake < x){
    sake += vec[count];
    count++;
  }
  cout << count + n - k << endl;
}

Submission Info

Submission Time
Task C - Sake or Water
User gushiro
Language C++23 (GCC 15.2.0)
Score 0
Code Size 502 Byte
Status WA
Exec Time 94 ms
Memory 5832 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 3
AC × 12
WA × 21
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 3436 KiB
example_01.txt AC 1 ms 3524 KiB
example_02.txt AC 1 ms 3592 KiB
hand_00.txt AC 84 ms 5692 KiB
hand_01.txt AC 83 ms 5716 KiB
hand_02.txt AC 73 ms 5832 KiB
hand_03.txt WA 73 ms 5832 KiB
hand_04.txt WA 73 ms 5692 KiB
hand_05.txt WA 73 ms 5616 KiB
hand_06.txt WA 74 ms 5580 KiB
hand_07.txt WA 1 ms 3604 KiB
hand_08.txt WA 1 ms 3484 KiB
hand_09.txt AC 1 ms 3552 KiB
hand_10.txt AC 1 ms 3656 KiB
hand_11.txt AC 83 ms 5716 KiB
random_00.txt WA 93 ms 5832 KiB
random_01.txt WA 94 ms 5728 KiB
random_02.txt WA 93 ms 5716 KiB
random_03.txt AC 93 ms 5768 KiB
random_04.txt WA 93 ms 5616 KiB
random_05.txt WA 93 ms 5716 KiB
random_06.txt WA 94 ms 5692 KiB
random_07.txt WA 93 ms 5692 KiB
random_08.txt WA 93 ms 5692 KiB
random_09.txt AC 94 ms 5728 KiB
random_10.txt WA 93 ms 5636 KiB
random_11.txt WA 94 ms 5712 KiB
random_12.txt WA 94 ms 5716 KiB
random_13.txt WA 94 ms 5688 KiB
random_14.txt WA 94 ms 5728 KiB
random_15.txt AC 94 ms 5712 KiB
random_16.txt WA 94 ms 5636 KiB
random_17.txt WA 93 ms 5768 KiB