提出 #72550156
ソースコード 拡げる
//#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include <stdlib.h>
#include<string>
#include<math.h>
#include<sstream>
#include<set>
#include<math.h>
#include <algorithm>
#include<map>
#include <numeric>
#include <sstream>
#include <iomanip>
#include<tuple>
#include <bitset>
#include <queue>
#include <iomanip>
#include <stack>
#include<time.h>
#include <unordered_set>
#include <random>
using namespace::std;
#define RANDMAX 100000
#define ll long long
#define lint long long int
#define ldouble long double
#define ALL(a) (a).begin(),(a).end()
using ve = vector<lint>;
vector<vector<int>> map2;
//
using Gra = vector<vector<lint>>;
using sve = vector<string>;
//
//cout << std::fixed << std::setprecision(15)<< ans;//�����_
//
//
//<stack>//�ォ��
// box.push()
// box.pop()
// box.top()
//
// <queue>������
// box.push()
// box.front()
// box.pop()
//
// <set>
// ite=g2.lower_bound(r) set�T��
// distance(ls.begin(), ite);�T��������̈���
// advance() �͋ɗ͎g��Ȃ����ƁI�I�@***************************************
// g2.count() set()���̌�
// lower_bound(a.begin(),a.end(),a[i])
// box.size()
//
// <vector>
// vector<int>
// lower_bound(a.begin(),a.end(),a[i])
// vector<vector<lint>> v(2, vector<lint>(3)) -> v.at(1).at(2);
// next_permutation(aaa.begin(), aaa.end()) �x�N�^�[�̑g�ݍ��킹
//
//<2���T���@�`�蓮�����`>
// int binary_search(int key) {
// int left = 0, right = (int)a.size() - 1; // �z�� a �̍��[�ƉE�[
// while (right >= left) {
// int mid = left + (right - left) / 2; // ��Ԃ̐^��
// if (a[mid] == key) return mid;
// else if (a[mid] > key) right = mid - 1;
// else if (a[mid] < key) left = mid + 1;
// }
// return -1;
// }
//
// <bit�S�T��>
//�@bitset<60> bs(n);
//
//�{��swap����Ƃ��͔��̔ԍ���ς���
/* par=time_check(nh, nm);
nh = par.first; nm = par.second;*/
pair<lint, lint> time_check(int h, int m) {
while (m >= 60) {
h += 1;
m -= 60;
}
while (m < 0) {
h -= 1;
m += 60;
}
return make_pair(h, m);
}
std::random_device seed_gen;
uint32_t get_rand() {
// ����������i�����ɃV�[�h���w��\�j
static std::mt19937 mt32(seed_gen());
// [0, (2^32)-1] �̈�l���z������
return mt32();
}
class ansd {
public:
int p;
int x;
int y;
};
class zahyo {
public:
int x;
int y;
};
lint n, max_p = 0, nowi, now_we, now_po, lost_p, max_w = 0;
int rec_dp(lint nowi, lint now_p, lint now_w, lint lost_p, vector<map<lint, lint>>& dp, ve& w, ve& p) {
if (dp[nowi].contains(now_w))return dp[nowi][now_w];
lint res = 0;
if (nowi == n) {
res = 0;
}
else if (now_w + w[nowi] > max_p - lost_p - p[nowi]) {
res = rec_dp(nowi + 1, now_p + p[nowi], now_w, lost_p, dp, w, p);
}
else {
res = max(
rec_dp(nowi + 1, now_p + p[nowi], now_w, lost_p, dp, w, p),
rec_dp(nowi + 1, now_p, now_w + w[nowi], lost_p + p[nowi], dp, w, p) + 1
);
}
return dp[nowi][now_w] = res;
}
int main() {
lint n, k, x;
cin >> n >> k >> x;
ve a(n);
lint all_sum = 0,min_sake = 0;;
for (lint i = 0; i < n; i++) {
cin >> a[i];
all_sum += a[i];
}
sort(ALL(a));
lint sum = 0;
for (lint i = 0; i < n; i++) {
sum += a[i];
if (i == n - 1||i>k-1) {
cout << -1 << endl; return 0;
}
if (sum >= x) {
//cout << i << endl;
cout << n - (k - i - 1);
break;
}
}
}
提出情報
| 提出日時 |
|
| 問題 |
C - Sake or Water |
| ユーザ |
tbbt95 |
| 言語 |
C++23 (GCC 15.2.0) |
| 得点 |
0 |
| コード長 |
3984 Byte |
| 結果 |
WA |
| 実行時間 |
89 ms |
| メモリ |
5768 KiB |
コンパイルエラー
./Main.cpp: In function 'int main()':
./Main.cpp:152:22: warning: unused variable 'min_sake' [-Wunused-variable]
152 | lint all_sum = 0,min_sake = 0;;
| ^~~~~~~~
ジャッジ結果
| セット名 |
Sample |
All |
| 得点 / 配点 |
0 / 0 |
0 / 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 |
3500 KiB |
| example_01.txt |
AC |
1 ms |
3600 KiB |
| example_02.txt |
AC |
1 ms |
3416 KiB |
| hand_00.txt |
WA |
79 ms |
5688 KiB |
| hand_01.txt |
AC |
78 ms |
5688 KiB |
| hand_02.txt |
AC |
69 ms |
5636 KiB |
| hand_03.txt |
WA |
69 ms |
5680 KiB |
| hand_04.txt |
WA |
69 ms |
5580 KiB |
| hand_05.txt |
WA |
69 ms |
5636 KiB |
| hand_06.txt |
WA |
69 ms |
5636 KiB |
| hand_07.txt |
WA |
1 ms |
3484 KiB |
| hand_08.txt |
WA |
1 ms |
3484 KiB |
| hand_09.txt |
WA |
1 ms |
3540 KiB |
| hand_10.txt |
AC |
1 ms |
3628 KiB |
| hand_11.txt |
AC |
78 ms |
5616 KiB |
| random_00.txt |
WA |
88 ms |
5712 KiB |
| random_01.txt |
WA |
88 ms |
5716 KiB |
| random_02.txt |
WA |
88 ms |
5712 KiB |
| random_03.txt |
AC |
87 ms |
5696 KiB |
| random_04.txt |
WA |
88 ms |
5768 KiB |
| random_05.txt |
WA |
87 ms |
5724 KiB |
| random_06.txt |
WA |
88 ms |
5688 KiB |
| random_07.txt |
WA |
88 ms |
5580 KiB |
| random_08.txt |
WA |
88 ms |
5712 KiB |
| random_09.txt |
AC |
89 ms |
5768 KiB |
| random_10.txt |
WA |
87 ms |
5688 KiB |
| random_11.txt |
WA |
88 ms |
5704 KiB |
| random_12.txt |
WA |
88 ms |
5692 KiB |
| random_13.txt |
WA |
87 ms |
5688 KiB |
| random_14.txt |
WA |
88 ms |
5580 KiB |
| random_15.txt |
AC |
88 ms |
5704 KiB |
| random_16.txt |
WA |
88 ms |
5712 KiB |
| random_17.txt |
WA |
89 ms |
5704 KiB |