Submission #400559

# Submission time Handle Problem Language Result Execution time Memory
400559 2021-05-08T10:25:50 Z b00n0rp A Difficult(y) Choice (BOI21_books) C++17
0 / 100
4 ms 200 KB
#include <bits/stdc++.h>
#include "books.h"
using namespace std;

long long a[100005];

// void solve(int N, int K, long long A, int S) {
//     for(int i = 1; i <= K; i ++) a[i] = skim(i);
//     int sm = 0;
// 	for(int i = 1; i <= K-1; i ++) sm += a[i];
// 	if(sm+a[K] > 2*A){
// 		impossible();
// 		return;
// 	}
//     int low = K,high = N,mid,ans;
// 	while(low <= high){
// 		mid = (low+high)/2;
// 		if(skim(mid)+sm <= 2*A){
// 			ans = mid;
// 			low = mid+1;
// 		}
// 		else high = mid-1;
// 	}
// 	for(int i = ans; i > ans-K; i --){
// 		sm += skim(i);
// 		if(sm >= A){
// 			vector<int> bruh;
// 			for(int j = i; j <= ans; j++) bruh.push_back(j);
// 			for(int j = 1; j <= K-(int)bruh.size(); j ++) bruh.push_back(j);
// 			answer(bruh);
// 			return;
// 		}
// 		sm -= a[K-(ans-i)-1];
// 	}
// 	impossible();
// }

void solve(int N, int K, long long A, int S) {
    for(int i = 1; i <= N; i ++) a[i] = skim(i);
    int sm = 0;
	for(int i = 1; i <= K-1; i ++) sm += a[i];
	if(sm+a[K] > 2*A){
		impossible();
		return;
	}
    int low = K,high = N,mid,ans;
	while(low <= high){
		mid = (low+high)/2;
		if(a[mid]+sm <= 2*A){
			ans = mid;
			low = mid+1;
		}
		else high = mid-1;
	}
	for(int i = ans; i > ans-K; i --){
		sm += a[i];
		if(sm >= A){
			vector<int> bruh;
			for(int j = i; j <= ans; j++) bruh.push_back(j);
			for(int j = 1; j <= K-(int)bruh.size(); j ++) bruh.push_back(j);
			sort(bruh.begin(),bruh.end());
			assert(sm <= 2*A);
			answer(bruh);
			return;
		}
		sm -= a[K-(ans-i)-1];
	}
	impossible();
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 200 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 200 KB Incorrect
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 4 ms 200 KB Execution killed with signal 13
2 Halted 0 ms 0 KB -