Submission #23434474


Source Code Expand

#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define ft first
#define sec second
#define pr pair<int,int>
#define ISCC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std; 
int t ,n ,m;
ll a[100005] ,k ,sum[100005];
vector<ll> vec;
int sol()
{
	int l = 0 ,r = n+1 ,mid;
	while(l<r)
	{
		mid = (l+r)>>1;
		//cout << sum[mid] << ' ' << l <<'\n';
		if(sum[mid] >= k) r = mid;
		else l = mid+1;
	}
	return l;
}
int main()
{ 
	ISCC;
	cin >> n >> m;
	for(int i=1 ;i<=n ;i++)
	{
		cin >> a[i];
		sum[i] = sum[i-1] + (a[i]-a[i-1]-1);
	}sum[n+1] = sum[n] + (1e18-a[n]-1);
	for(int i=1 ,now ;i<=m ;i++)
	{
		cin >> k;  now = sol()-1;
		cout << a[now] + abs(k-sum[now]) << '\n';
	}
	
	return 0;
}

Submission Info

Submission Time
Task D - Kth Excluded
User ck1080012
Language C++ (GCC 9.2.1)
Score 400
Code Size 785 Byte
Status AC
Exec Time 62 ms
Memory 5208 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 2
AC × 19
Set Name Test Cases
Sample example_00.txt, example_01.txt
All block_00.txt, block_01.txt, block_02.txt, block_03.txt, block_04.txt, example_00.txt, example_01.txt, killer_00.txt, killer_01.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
Case Name Status Exec Time Memory
block_00.txt AC 50 ms 5152 KiB
block_01.txt AC 39 ms 4600 KiB
block_02.txt AC 34 ms 4476 KiB
block_03.txt AC 30 ms 3920 KiB
block_04.txt AC 14 ms 3548 KiB
example_00.txt AC 2 ms 3508 KiB
example_01.txt AC 2 ms 3552 KiB
killer_00.txt AC 62 ms 5088 KiB
killer_01.txt AC 33 ms 5208 KiB
random_00.txt AC 57 ms 5092 KiB
random_01.txt AC 14 ms 3576 KiB
random_02.txt AC 49 ms 4920 KiB
random_03.txt AC 47 ms 4640 KiB
random_04.txt AC 29 ms 4952 KiB
random_05.txt AC 50 ms 4672 KiB
random_06.txt AC 21 ms 3688 KiB
random_07.txt AC 30 ms 4376 KiB
random_08.txt AC 47 ms 4984 KiB
random_09.txt AC 52 ms 4768 KiB