Submission #75637672


Source Code Expand

#include <bits/stdc++.h>
#define int long long
#define ull unsigned long long
#define inf 2e18
#define eps 1e-9
#define il inline
#define ls 2*k
#define rs 2*k+1
using namespace std;
const int N=2e5+5,M=4e5+5;
const int mod=1e9+7;
inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int n,a[N],k;
inline bool check(int w){
	int res=0;
	for(int i=1;i<=n;i++){
		if(a[i]>=w) continue;
		int d=w-a[i];
		res=res+(d+i-1)/i;
		if(res>k) return false;
	}
	return res<=k;
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	
	int tc=1;
	while(tc--){
		cin>>n>>k;
		for(int i=1;i<=n;i++) cin>>a[i];
		int l=1,r=inf;
		while(l<r){
			int mid=(l+r+1)>>1;
			if(check(mid)) l=mid;
			else r=mid-1;
		}
		cout<<l<<'\n';
	} 
	
	return 0;
}

Submission Info

Submission Time
Task D - Raise Minimum
User Limingxuan
Language C++23 (GCC 15.2.0)
Score 400
Code Size 958 Byte
Status AC
Exec Time 64 ms
Memory 5256 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 47
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_corner_00.txt, 01_corner_01.txt, 01_corner_02.txt, 01_corner_03.txt, 01_corner_04.txt, 01_corner_05.txt, 01_corner_06.txt, 01_corner_07.txt, 01_corner_08.txt, 01_corner_09.txt, 01_corner_10.txt, 02_hack_00.txt, 02_hack_01.txt, 02_hack_02.txt, 02_hack_03.txt, 02_hack_04.txt, 02_hack_05.txt, 02_hack_06.txt, 02_hack_07.txt, 02_hack_08.txt, 02_hack_09.txt, 02_hack_10.txt, 02_hack_11.txt, 02_hack_12.txt, 03_random_00.txt, 03_random_01.txt, 03_random_02.txt, 03_random_03.txt, 03_random_04.txt, 03_random_05.txt, 03_random_06.txt, 03_random_07.txt, 03_random_08.txt, 03_random_09.txt, 03_random_10.txt, 03_random_11.txt, 03_random_12.txt, 03_random_13.txt, 03_random_14.txt, 03_random_15.txt, 03_random_16.txt, 03_random_17.txt, 03_random_18.txt, 03_random_19.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3560 KiB
00_sample_01.txt AC 1 ms 3592 KiB
00_sample_02.txt AC 1 ms 3472 KiB
01_corner_00.txt AC 1 ms 3460 KiB
01_corner_01.txt AC 6 ms 5060 KiB
01_corner_02.txt AC 1 ms 3384 KiB
01_corner_03.txt AC 49 ms 5116 KiB
01_corner_04.txt AC 40 ms 5248 KiB
01_corner_05.txt AC 41 ms 5192 KiB
01_corner_06.txt AC 38 ms 5256 KiB
01_corner_07.txt AC 39 ms 5060 KiB
01_corner_08.txt AC 39 ms 5224 KiB
01_corner_09.txt AC 38 ms 5076 KiB
01_corner_10.txt AC 39 ms 5096 KiB
02_hack_00.txt AC 1 ms 3432 KiB
02_hack_01.txt AC 1 ms 3508 KiB
02_hack_02.txt AC 1 ms 3412 KiB
02_hack_03.txt AC 1 ms 3452 KiB
02_hack_04.txt AC 6 ms 4916 KiB
02_hack_05.txt AC 6 ms 4820 KiB
02_hack_06.txt AC 3 ms 3764 KiB
02_hack_07.txt AC 21 ms 4692 KiB
02_hack_08.txt AC 27 ms 5008 KiB
02_hack_09.txt AC 12 ms 3988 KiB
02_hack_10.txt AC 37 ms 4924 KiB
02_hack_11.txt AC 15 ms 4040 KiB
02_hack_12.txt AC 17 ms 4032 KiB
03_random_00.txt AC 59 ms 5192 KiB
03_random_01.txt AC 57 ms 5128 KiB
03_random_02.txt AC 43 ms 5076 KiB
03_random_03.txt AC 10 ms 3944 KiB
03_random_04.txt AC 58 ms 5136 KiB
03_random_05.txt AC 31 ms 4240 KiB
03_random_06.txt AC 43 ms 5060 KiB
03_random_07.txt AC 2 ms 3588 KiB
03_random_08.txt AC 64 ms 5116 KiB
03_random_09.txt AC 15 ms 3968 KiB
03_random_10.txt AC 23 ms 5176 KiB
03_random_11.txt AC 16 ms 4112 KiB
03_random_12.txt AC 63 ms 5076 KiB
03_random_13.txt AC 34 ms 4464 KiB
03_random_14.txt AC 52 ms 5224 KiB
03_random_15.txt AC 19 ms 4368 KiB
03_random_16.txt AC 48 ms 5060 KiB
03_random_17.txt AC 48 ms 5256 KiB
03_random_18.txt AC 48 ms 5184 KiB
03_random_19.txt AC 48 ms 5060 KiB