Submission #72554837
Source Code Expand
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
#include <numeric>
using namespace std;
#define ll long long
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vii vector<pair<int, int>>
#define vllvector vector<pair<ll, ll>>
#define vb vector<bool>
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define rep(i, c, n) for (int i = c; i < n; i++)
const long long llINF = 1LL << 60;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
//! int型でinfを使うならINT_MAX使う
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll n, k, x;
cin >> n >> k >> x;
vll cup(n);
rep(i, 0, n) {
cin >> cup[i];
}
sort(cup.begin(), cup.end());
vll ruisekiwa(n +1, 0);
rep(i, 0, n) ruisekiwa[i +1] = ruisekiwa[i] + cup[i];
for(int m = 1; m<= n; m++) {
ll sake = max(0LL, m -(n-k));
if(sake <= 0) continue;
ll sum = ruisekiwa[sake];
if(sum >= x) {
cout << m << endl;
return 0;
}
}
cout << -1 << endl;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Sake or Water |
| User | kar1neko |
| Language | C++23 (GCC 15.2.0) |
| Score | 0 |
| Code Size | 1392 Byte |
| Status | WA |
| Exec Time | 37 ms |
| Memory | 8012 KiB |
Judge Result
| Set Name | Sample | All | ||||||
|---|---|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 0 / 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 | 3508 KiB |
| example_01.txt | AC | 1 ms | 3596 KiB |
| example_02.txt | AC | 1 ms | 3564 KiB |
| hand_00.txt | AC | 19 ms | 7964 KiB |
| hand_01.txt | AC | 19 ms | 7948 KiB |
| hand_02.txt | AC | 35 ms | 7864 KiB |
| hand_03.txt | WA | 35 ms | 7992 KiB |
| hand_04.txt | WA | 35 ms | 8004 KiB |
| hand_05.txt | WA | 35 ms | 7948 KiB |
| hand_06.txt | WA | 35 ms | 7884 KiB |
| hand_07.txt | WA | 1 ms | 3508 KiB |
| hand_08.txt | WA | 2 ms | 3556 KiB |
| hand_09.txt | AC | 1 ms | 3564 KiB |
| hand_10.txt | AC | 2 ms | 3488 KiB |
| hand_11.txt | AC | 19 ms | 7964 KiB |
| random_00.txt | WA | 36 ms | 7936 KiB |
| random_01.txt | WA | 37 ms | 7924 KiB |
| random_02.txt | WA | 37 ms | 7948 KiB |
| random_03.txt | AC | 36 ms | 7948 KiB |
| random_04.txt | WA | 36 ms | 7872 KiB |
| random_05.txt | WA | 35 ms | 7992 KiB |
| random_06.txt | WA | 36 ms | 7984 KiB |
| random_07.txt | WA | 36 ms | 7936 KiB |
| random_08.txt | WA | 35 ms | 7936 KiB |
| random_09.txt | AC | 36 ms | 7964 KiB |
| random_10.txt | WA | 36 ms | 7964 KiB |
| random_11.txt | WA | 36 ms | 7984 KiB |
| random_12.txt | WA | 36 ms | 7884 KiB |
| random_13.txt | WA | 36 ms | 7964 KiB |
| random_14.txt | WA | 36 ms | 7964 KiB |
| random_15.txt | AC | 35 ms | 7964 KiB |
| random_16.txt | WA | 36 ms | 8012 KiB |
| random_17.txt | WA | 36 ms | 7968 KiB |