Submission #58777011


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
#define LL long long
int T;
int n,a[N],b[N];
LL s[N],p[N];
int main()
{
// freopen("in.in","r",stdin);
// freopen("out.out","w",stdout);
scanf("%d",&T);
while(T--)
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]); s[i]=s[i-1]+a[i];
}
LL sum=0,now=a[1],tot=a[1];
for(int i=2;i<=n;i++)
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
#define LL long long
int T;
int n,a[N],b[N];
LL s[N],p[N];
int main()
{
	// freopen("in.in","r",stdin);
	// freopen("out.out","w",stdout);
	scanf("%d",&T);
	while(T--)
	{
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d",&a[i]); s[i]=s[i-1]+a[i];
		}
		LL sum=0,now=a[1],tot=a[1];
		for(int i=2;i<=n;i++)
		{
			if(now>a[i])
			{
				sum+=a[i]-now;
				tot+=now;
			}
			else
			{
				LL tmp=min(-sum,a[i]-now);
				sum+=tmp;
				tot+=a[i]-tmp;
				if(tot)	now=(tot-1)/(i)+1;
				else now=0;
			}
		}
		if(sum>=0) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Submission Info

Submission Time
Task B - +1 and -1
User ppllxx
Language C++ 20 (gcc 12.2)
Score 600
Code Size 685 Byte
Status AC
Exec Time 30 ms
Memory 6116 KB

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%d",&T);
      |         ~~~~~^~~~~~~~~
Main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |                 scanf("%d",&n);
      |                 ~~~~~^~~~~~~~~
Main.cpp:18:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |                         scanf("%d",&a[i]); s[i]=s[i-1]+a[i];
      |                         ~~~~~^~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 1
AC × 71
Set Name Test Cases
Sample 00_sample_00.txt
All 00_sample_00.txt, 01_n_small_00.txt, 01_n_small_01.txt, 01_n_small_02.txt, 01_n_small_03.txt, 01_n_small_04.txt, 01_n_small_05.txt, 01_n_small_06.txt, 01_n_small_07.txt, 01_n_small_08.txt, 01_n_small_09.txt, 01_n_small_10.txt, 01_n_small_11.txt, 01_n_small_12.txt, 01_n_small_13.txt, 01_n_small_14.txt, 01_n_small_15.txt, 01_n_small_16.txt, 01_n_small_17.txt, 01_n_small_18.txt, 01_n_small_19.txt, 01_n_small_20.txt, 01_n_small_21.txt, 01_n_small_22.txt, 01_n_small_23.txt, 01_n_small_24.txt, 01_n_small_25.txt, 01_n_small_26.txt, 01_n_small_27.txt, 01_n_small_28.txt, 01_n_small_29.txt, 01_n_small_30.txt, 01_n_small_31.txt, 01_n_small_32.txt, 01_n_small_33.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt, 03_random_2_00.txt, 03_random_2_01.txt, 03_random_2_02.txt, 03_random_2_03.txt, 03_random_2_04.txt, 03_random_2_05.txt, 03_random_2_06.txt, 03_random_2_07.txt, 03_random_2_08.txt, 03_random_2_09.txt, 04_random_3_00.txt, 04_random_3_01.txt, 04_random_3_02.txt, 04_random_3_03.txt, 04_random_3_04.txt, 05_random_4_00.txt, 05_random_4_01.txt, 05_random_4_02.txt, 05_random_4_03.txt, 05_random_4_04.txt, 05_random_4_05.txt, 05_random_4_06.txt, 05_random_4_07.txt, 05_random_4_08.txt, 05_random_4_09.txt, 06_corner_00.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3656 KB
01_n_small_00.txt AC 13 ms 3704 KB
01_n_small_01.txt AC 14 ms 3584 KB
01_n_small_02.txt AC 13 ms 3884 KB
01_n_small_03.txt AC 13 ms 3588 KB
01_n_small_04.txt AC 13 ms 3884 KB
01_n_small_05.txt AC 13 ms 3880 KB
01_n_small_06.txt AC 13 ms 3704 KB
01_n_small_07.txt AC 13 ms 3776 KB
01_n_small_08.txt AC 14 ms 3692 KB
01_n_small_09.txt AC 14 ms 3700 KB
01_n_small_10.txt AC 13 ms 3704 KB
01_n_small_11.txt AC 13 ms 3524 KB
01_n_small_12.txt AC 13 ms 3704 KB
01_n_small_13.txt AC 13 ms 3648 KB
01_n_small_14.txt AC 13 ms 3656 KB
01_n_small_15.txt AC 13 ms 3880 KB
01_n_small_16.txt AC 13 ms 3708 KB
01_n_small_17.txt AC 13 ms 3588 KB
01_n_small_18.txt AC 13 ms 3668 KB
01_n_small_19.txt AC 17 ms 3524 KB
01_n_small_20.txt AC 28 ms 3772 KB
01_n_small_21.txt AC 26 ms 3700 KB
01_n_small_22.txt AC 26 ms 3672 KB
01_n_small_23.txt AC 25 ms 3716 KB
01_n_small_24.txt AC 25 ms 3772 KB
01_n_small_25.txt AC 26 ms 3772 KB
01_n_small_26.txt AC 25 ms 3884 KB
01_n_small_27.txt AC 24 ms 3588 KB
01_n_small_28.txt AC 24 ms 3524 KB
01_n_small_29.txt AC 24 ms 3664 KB
01_n_small_30.txt AC 24 ms 3640 KB
01_n_small_31.txt AC 25 ms 3520 KB
01_n_small_32.txt AC 24 ms 3672 KB
01_n_small_33.txt AC 8 ms 3536 KB
02_random_00.txt AC 29 ms 3520 KB
02_random_01.txt AC 28 ms 3700 KB
02_random_02.txt AC 25 ms 3700 KB
02_random_03.txt AC 23 ms 3644 KB
02_random_04.txt AC 22 ms 3772 KB
02_random_05.txt AC 23 ms 3596 KB
02_random_06.txt AC 22 ms 3640 KB
02_random_07.txt AC 22 ms 3832 KB
02_random_08.txt AC 23 ms 4412 KB
02_random_09.txt AC 24 ms 5860 KB
03_random_2_00.txt AC 29 ms 3724 KB
03_random_2_01.txt AC 27 ms 3700 KB
03_random_2_02.txt AC 24 ms 3880 KB
03_random_2_03.txt AC 23 ms 3692 KB
03_random_2_04.txt AC 23 ms 3772 KB
03_random_2_05.txt AC 23 ms 3708 KB
03_random_2_06.txt AC 22 ms 3932 KB
03_random_2_07.txt AC 23 ms 3836 KB
03_random_2_08.txt AC 24 ms 4376 KB
03_random_2_09.txt AC 24 ms 5856 KB
04_random_3_00.txt AC 24 ms 6044 KB
04_random_3_01.txt AC 24 ms 6004 KB
04_random_3_02.txt AC 24 ms 6116 KB
04_random_3_03.txt AC 24 ms 6044 KB
04_random_3_04.txt AC 24 ms 6036 KB
05_random_4_00.txt AC 28 ms 3640 KB
05_random_4_01.txt AC 27 ms 3688 KB
05_random_4_02.txt AC 25 ms 3652 KB
05_random_4_03.txt AC 23 ms 3580 KB
05_random_4_04.txt AC 23 ms 3888 KB
05_random_4_05.txt AC 22 ms 3704 KB
05_random_4_06.txt AC 23 ms 3752 KB
05_random_4_07.txt AC 22 ms 3884 KB
05_random_4_08.txt AC 23 ms 4288 KB
05_random_4_09.txt AC 30 ms 5100 KB
06_corner_00.txt AC 16 ms 5980 KB


2025-03-05 (Wed)
20:38:41 +00:00