Submission #71012828


Source Code Expand

/*
*            /$$           /$$
*           |__/          |__/
*  /$$$$$$$$ /$$ /$$$$$$$$ /$$  /$$$$$$
* |____ /$$/| $$|____ /$$/| $$ /$$__  $$
*    /$$$$/ | $$   /$$$$/ | $$| $$  \ $$
*   /$$__/  | $$  /$$__/  | $$| $$  | $$
*  /$$$$$$$$| $$ /$$$$$$$$| $$|  $$$$$$$
* |________/|__/|________/|__/ \____  $$
*                                   | $$
*                                   | $$
*                                   |__/
*/
//hj23308±£ÓÓÎÒ
//Missile±£ÓÓÎÒ
/*
* ÐÑÁËÔÚÃÎÀïÕõÔú£¬²»¾õ÷öµ­Á˳¯Ï¼
*/
/*
* ÎҺܸßÐËÄãûÓÐÍüÁËÎÒ£¬µ«ÊÇÎÒÏÖÔÚ¸üÏ£ÍûÄãÒѾ­ÍüÁËÎÒÁË¡£
* Ï£ÍûÔÚÄãµÄ¼ÇÒäÖУ¬ÎÒÖ»Êdz¾ÍÁÒ»´é£¬´ÓÄãµÄÈ«ÊÀ½ç·¹ý£¬È»ºóËÄÉ¢·ÉÑï²»ÁôÏÂÒ»µãºÛ¼££¬¶øÄãÒª²»»ØÍ·µÄÍùǰ×ß¡£
* ÎÒ¸üÏ£ÍûÎÒÖ»ÊÇ´ÓÄãµÄÈ«ÊÀ½ç·¹ý£¬Ö»ÊÇ·¹ý
*/
/*
* Ö»ÊÇÎÒÔÚÊ®×Ö·¿ÚÊØÁËÌ«¾Ã£¬Êص½»ÆÉ³ÈçÓêÑÚÂñÒ»Çкۼ££¬²Å·¢ÏÖ×Ô¼ºµÈµÄÈËÒѾ­À뿪ÁË¡£
*/
/*
* ÌýÎÒµÄ ±ð»ØÍ· »ØÍ·¾Í¿ÉÄÜ»áÀáÁ÷ÂúÃæ£¬»á±»»ÆÉ³ÑÚÂñ£¬ËùÒÔ¼´Ê¹Í´¿àÒ²ÒªÏòǰ×ß
*/
/*
* ÎÒÌýµ½ÁË¡¸ÌìÐн¡¡¹µÄ»ØÏ죬ÕâÊÇÒ»¸öΰ´ó¶·Ê¿µÄ²»Ï¢×ÔÇ¿£»
* ÎÒÌýµ½ÁË¡¸ÆÆÍò·¨¡¹µÄ»ØÏ죬ÕâÊÇÒ»¸öºÚµÀ´òÊÖµÄÊØ»¤ÓûÍû£»
* ÎÒ¿´¼ûÁË¡¸ÉúÉú²»Ï¢¡¹µÄ¼¤µ´£¬ÕâÊÇÒ»¸öÆ­×ÓµÄΰ´óÀÖÕ£¡
*/
/*
* ÎÒÓÃÐé¼ÙµÄÃæ¾ßÕÕ¹Ë×ÅϸÄåµÄ¸ÐÇ飻
* ÎÒÒÔ»ªÀöµÄÒÂÎïϲØ×Ÿ¯ÀõÄѪÈ⣻
* µ±ÎÒÕªÏÂÃæ¾ß£¬ÍÊÈ¥ÒÂÎ¼´±ãÊÇÎÒ×îÇ×½üµÄÈË£¬Ò²ÎÞ·¨Ö±ÊÓÎÒ
*/
#include<bits/stdc++.h>
#define mk make_pair
using namespace std;
mt19937 engine(chrono::steady_clock().now().time_since_epoch().count());
const int MAXN=2e5+5;
int t,n,m;
long long a[MAXN],num[MAXN];
struct Large {
	int N;
	long long sum[2*MAXN];
	void newN() {
		sum[++N]=0;
	}
	void init() {
		N=0;
	}
	void Add(int pos,long long val) {
//		cout<<"add : "<<pos<<" , "<<val<<"\n";
		while(N<pos) newN();
		long long res=0;
		for(int i=pos;val||res;i++) {
			if(N<i) newN();
			sum[i]+=res+val%10;
			res=0,val/=10;
			while(sum[i]>=10) sum[i]-=10,res++;
		}
	}
	void Cout() {
		bool flag=false;
		for(int i=N;i>=1;i--) {
			if(!flag&&sum[i]==0) continue;
			flag=true;
			cout<<sum[i];
		}
		if(!flag) cout<<"0";
		cout<<"\n";
	}
}number;
void Solve()
{
	number.init();
	for(int i=1;i<=n;i++) {
		num[i+1]+=num[i]/10;
	}
	long long res=0;
	for(int i=n;i>=1;i--) {
		res*=10;
		long long val=min(res,a[i]);
//		cout<<"res : "<<res<<"\n";
		a[i]-=val,num[i]-=res,res-=val;
//		cout<<i<<" : "<<num[i]<<"\n";
		long long sum=num[i]/m,oth=sum*m-a[i];
		number.Add(i,sum);
		res+=max(0ll,oth);
	}
	number.Cout();
}
int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>t;
	while(t--) {
		cin>>n>>m;
		for(int i=1;i<=n;i++) {
			cin>>a[i];
			num[i]=a[i];
		}
		Solve();
	}
	return 0;
}

Submission Info

Submission Time
Task C - Fair Coin Partition
User Ziziq
Language C++23 (GCC 15.2.0)
Score 700
Code Size 3346 Byte
Status AC
Exec Time 17 ms
Memory 8404 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 700 / 700
Status
AC × 1
AC × 62
Set Name Test Cases
Sample 01_sample_01.txt
All 01_sample_01.txt, 02_many_small_01.txt, 02_many_small_02.txt, 02_many_small_03.txt, 02_many_small_04.txt, 02_many_small_05.txt, 02_many_small_06.txt, 02_many_small_07.txt, 02_many_small_08.txt, 02_many_small_09.txt, 02_many_small_10.txt, 02_many_small_11.txt, 02_many_small_12.txt, 02_many_small_13.txt, 02_many_small_14.txt, 02_many_small_15.txt, 02_many_small_16.txt, 02_many_small_17.txt, 02_many_small_18.txt, 02_many_small_19.txt, 02_many_small_20.txt, 03_mid_01.txt, 03_mid_02.txt, 03_mid_03.txt, 03_mid_04.txt, 03_mid_05.txt, 03_mid_06.txt, 03_mid_07.txt, 03_mid_08.txt, 03_mid_09.txt, 03_mid_10.txt, 03_mid_11.txt, 03_mid_12.txt, 03_mid_13.txt, 03_mid_14.txt, 03_mid_15.txt, 03_mid_16.txt, 03_mid_17.txt, 03_mid_18.txt, 03_mid_19.txt, 03_mid_20.txt, 04_max_rand_01.txt, 04_max_rand_02.txt, 04_max_rand_03.txt, 04_max_rand_04.txt, 04_max_rand_05.txt, 04_max_rand_06.txt, 04_max_rand_07.txt, 04_max_rand_08.txt, 04_max_rand_09.txt, 04_max_rand_10.txt, 04_max_rand_11.txt, 04_max_rand_12.txt, 04_max_rand_13.txt, 04_max_rand_14.txt, 04_max_rand_15.txt, 04_max_rand_16.txt, 04_max_rand_17.txt, 04_max_rand_18.txt, 04_max_rand_19.txt, 04_max_rand_20.txt, 04_max_rand_21.txt
Case Name Status Exec Time Memory
01_sample_01.txt AC 1 ms 3772 KiB
02_many_small_01.txt AC 17 ms 3772 KiB
02_many_small_02.txt AC 17 ms 3716 KiB
02_many_small_03.txt AC 17 ms 3588 KiB
02_many_small_04.txt AC 17 ms 3588 KiB
02_many_small_05.txt AC 17 ms 3704 KiB
02_many_small_06.txt AC 17 ms 3788 KiB
02_many_small_07.txt AC 17 ms 3772 KiB
02_many_small_08.txt AC 17 ms 3700 KiB
02_many_small_09.txt AC 17 ms 3712 KiB
02_many_small_10.txt AC 17 ms 3668 KiB
02_many_small_11.txt AC 17 ms 3772 KiB
02_many_small_12.txt AC 17 ms 3588 KiB
02_many_small_13.txt AC 17 ms 3636 KiB
02_many_small_14.txt AC 16 ms 3664 KiB
02_many_small_15.txt AC 17 ms 3684 KiB
02_many_small_16.txt AC 17 ms 3664 KiB
02_many_small_17.txt AC 17 ms 3772 KiB
02_many_small_18.txt AC 17 ms 3788 KiB
02_many_small_19.txt AC 17 ms 3772 KiB
02_many_small_20.txt AC 17 ms 3708 KiB
03_mid_01.txt AC 14 ms 3828 KiB
03_mid_02.txt AC 13 ms 3800 KiB
03_mid_03.txt AC 13 ms 3796 KiB
03_mid_04.txt AC 13 ms 3792 KiB
03_mid_05.txt AC 13 ms 3724 KiB
03_mid_06.txt AC 14 ms 3772 KiB
03_mid_07.txt AC 13 ms 3772 KiB
03_mid_08.txt AC 14 ms 3924 KiB
03_mid_09.txt AC 13 ms 3784 KiB
03_mid_10.txt AC 14 ms 3908 KiB
03_mid_11.txt AC 13 ms 3832 KiB
03_mid_12.txt AC 14 ms 3772 KiB
03_mid_13.txt AC 13 ms 3828 KiB
03_mid_14.txt AC 13 ms 3800 KiB
03_mid_15.txt AC 14 ms 3712 KiB
03_mid_16.txt AC 13 ms 3844 KiB
03_mid_17.txt AC 13 ms 3900 KiB
03_mid_18.txt AC 13 ms 3836 KiB
03_mid_19.txt AC 13 ms 3716 KiB
03_mid_20.txt AC 13 ms 3764 KiB
04_max_rand_01.txt AC 16 ms 8380 KiB
04_max_rand_02.txt AC 15 ms 8244 KiB
04_max_rand_03.txt AC 12 ms 8312 KiB
04_max_rand_04.txt AC 15 ms 8312 KiB
04_max_rand_05.txt AC 16 ms 8244 KiB
04_max_rand_06.txt AC 15 ms 8280 KiB
04_max_rand_07.txt AC 15 ms 8264 KiB
04_max_rand_08.txt AC 16 ms 8312 KiB
04_max_rand_09.txt AC 16 ms 8380 KiB
04_max_rand_10.txt AC 13 ms 8252 KiB
04_max_rand_11.txt AC 16 ms 8316 KiB
04_max_rand_12.txt AC 16 ms 8384 KiB
04_max_rand_13.txt AC 15 ms 8308 KiB
04_max_rand_14.txt AC 15 ms 8244 KiB
04_max_rand_15.txt AC 16 ms 8280 KiB
04_max_rand_16.txt AC 15 ms 8380 KiB
04_max_rand_17.txt AC 13 ms 8404 KiB
04_max_rand_18.txt AC 15 ms 8316 KiB
04_max_rand_19.txt AC 16 ms 8324 KiB
04_max_rand_20.txt AC 16 ms 8272 KiB
04_max_rand_21.txt AC 15 ms 8396 KiB