QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#241401#3025. AssimilationclimaxcxRE 0ms0kbC++14914b2023-11-06 05:30:372023-11-06 05:30:38

Judging History

你现在查看的是最新测评结果

  • [2023-11-06 05:30:38]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-11-06 05:30:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int inf = 2000000001;
bool check(int n, int mob, multiset<int>S, long long k){
	 for(int i = 0; i < mob; i++){
		 auto it = S.upper_bound(k);
		 it--;
		 if(*it == -1)return false;
		 k += *it;
		 S.erase(it);
	 }
	 for(int i = 0; i < n - mob; i++){
		 auto it = S.upper_bound(k);
		 it--;
		 if(*it == -1)return false;
		 k -= *it;
		 S.erase(it);
	 }
	 return true;
 }
		 
 
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int z;
	cin >> z;
	while(z--){
		int n;
		long long k;
		cin >> n >> k;
		multiset<int>S;
		for(int i = 0; i < n; i++){
			int x;
			cin >> x;
			S.insert(x);
		}
		S.insert(-1);
		int l = 0, r = n;
		while(l <= r){
			int mid = l + (r-l)/2;
			if(check(n, mid, S, k))r = mid - 1;
			else l = mid + 1;
		}
		if(l == n + 1)cout << "-1\n";
		else cout << l << '\n';
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Runtime Error

input:

29
9 1
1 1 2 1 1 1 1 1 1
4 1
3 2 1 1
5 316660370
269357435 105688553 346785866 295093544 181703417
6 43402885
39947441 27068237 43810814 44913378 40095941 34779892
22 319594
3815194 3056481 6593888 7315914 6593888 4794774 2561877 5256242 4920603 5256242 3606645 864746 1594265 1235578 2361430 2277526...

output:


result: