Submission #38021237


Source Code Expand

#if IN_LOCAL
import local;
#endif // IN_LOCAL
#include<cmath>
#include<iostream>
using namespace std;
int a[200002];
long long ans[200002];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n;
	cin >> n;
	for (int i = 1; i <= n; cin >> a[i++]);
	for (int i = n; i > 1; a[i - 1] += a[i], --i);
	if (a[1])
	{
		const int x = abs(a[1]);
		long long sum = 0;
		for (int i = 2; i <= n; sum += a[i], ans[i++] = x);
		ans[1] = (a[1] > 0 ? -sum : sum);
	}
	else
	{
		int p = 2;
		for (; p <= n && a[p] != -1; ++p);
		int q = 2;
		for (; q <= n && a[q] != 1; ++q);
		if (p > n || q > n)
		{
			cout << "No";
			return 0;
		}
		long long sum = 0;
		for (int i = 2; i <= n; sum += a[i++]);
		if (sum > 0)
		{
			for (int i = 1; i <= n; ans[i++] = 1);
			ans[p] += sum;
		}
		else
		{
			for (int i = 1; i <= n; ans[i++] = 1);
			ans[q] -= sum;
		}
	}
	cout << "Yes\n";
	long long sum = 0;
	for (int i = 1; i <= n; cout << (sum += ans[i++]) << ' ');
	return 0;
}

Submission Info

Submission Time
Task C - ± Increasing Sequence
User LXl491214
Language C++ (Clang 10.0.0)
Score 600
Code Size 1039 Byte
Status AC
Exec Time 116 ms
Memory 5504 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 600 / 600
Status
AC × 3
AC × 76
Set Name Test Cases
Sample 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt
All 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 02_small_1_01.txt, 02_small_1_02.txt, 02_small_1_03.txt, 02_small_1_04.txt, 02_small_1_05.txt, 02_small_1_06.txt, 02_small_1_07.txt, 02_small_1_08.txt, 02_small_1_09.txt, 02_small_1_10.txt, 02_small_1_11.txt, 02_small_1_12.txt, 02_small_1_13.txt, 02_small_1_14.txt, 03_small_2_01.txt, 03_small_2_02.txt, 03_small_2_03.txt, 03_small_2_04.txt, 03_small_2_05.txt, 03_small_2_06.txt, 03_small_2_07.txt, 03_small_2_08.txt, 03_small_2_09.txt, 03_small_2_10.txt, 04_small_zero_01.txt, 04_small_zero_02.txt, 04_small_zero_03.txt, 04_small_zero_04.txt, 05_small_bracket_01.txt, 05_small_bracket_02.txt, 05_small_bracket_03.txt, 05_small_bracket_04.txt, 06_max_rand_01.txt, 06_max_rand_02.txt, 06_max_rand_03.txt, 06_max_rand_04.txt, 06_max_rand_05.txt, 06_max_rand_06.txt, 06_max_rand_07.txt, 06_max_rand_08.txt, 06_max_rand_09.txt, 06_max_rand_10.txt, 07_max_zero_01.txt, 07_max_zero_02.txt, 07_max_zero_03.txt, 07_max_zero_04.txt, 07_max_zero_05.txt, 07_max_zero_06.txt, 07_max_zero_07.txt, 07_max_zero_08.txt, 07_max_zero_09.txt, 07_max_zero_10.txt, 08_max_bracket_01.txt, 08_max_bracket_02.txt, 08_max_bracket_03.txt, 08_max_bracket_04.txt, 08_max_bracket_05.txt, 08_max_bracket_06.txt, 08_max_bracket_07.txt, 08_max_bracket_08.txt, 08_max_bracket_09.txt, 08_max_bracket_10.txt, 09_almost_same_01.txt, 09_almost_same_02.txt, 09_almost_same_03.txt, 09_almost_same_04.txt, 09_almost_same_05.txt, 10_handmade_01.txt, 10_handmade_02.txt, 10_handmade_03.txt, 10_handmade_04.txt, 10_handmade_05.txt, 10_handmade_06.txt
Case Name Status Exec Time Memory
01_sample_01.txt AC 11 ms 3088 KiB
01_sample_02.txt AC 2 ms 3108 KiB
01_sample_03.txt AC 2 ms 2816 KiB
02_small_1_01.txt AC 3 ms 3132 KiB
02_small_1_02.txt AC 2 ms 3032 KiB
02_small_1_03.txt AC 2 ms 3140 KiB
02_small_1_04.txt AC 2 ms 3008 KiB
02_small_1_05.txt AC 2 ms 3012 KiB
02_small_1_06.txt AC 2 ms 3112 KiB
02_small_1_07.txt AC 2 ms 3136 KiB
02_small_1_08.txt AC 2 ms 3164 KiB
02_small_1_09.txt AC 2 ms 3024 KiB
02_small_1_10.txt AC 3 ms 3140 KiB
02_small_1_11.txt AC 2 ms 3012 KiB
02_small_1_12.txt AC 2 ms 3144 KiB
02_small_1_13.txt AC 4 ms 3080 KiB
02_small_1_14.txt AC 2 ms 3076 KiB
03_small_2_01.txt AC 2 ms 3000 KiB
03_small_2_02.txt AC 2 ms 3068 KiB
03_small_2_03.txt AC 3 ms 3032 KiB
03_small_2_04.txt AC 3 ms 3140 KiB
03_small_2_05.txt AC 2 ms 2992 KiB
03_small_2_06.txt AC 2 ms 2992 KiB
03_small_2_07.txt AC 2 ms 3136 KiB
03_small_2_08.txt AC 4 ms 3140 KiB
03_small_2_09.txt AC 2 ms 3196 KiB
03_small_2_10.txt AC 3 ms 3012 KiB
04_small_zero_01.txt AC 1 ms 3080 KiB
04_small_zero_02.txt AC 2 ms 3160 KiB
04_small_zero_03.txt AC 3 ms 3088 KiB
04_small_zero_04.txt AC 2 ms 3012 KiB
05_small_bracket_01.txt AC 3 ms 2860 KiB
05_small_bracket_02.txt AC 2 ms 3016 KiB
05_small_bracket_03.txt AC 2 ms 3020 KiB
05_small_bracket_04.txt AC 2 ms 3012 KiB
06_max_rand_01.txt AC 116 ms 5448 KiB
06_max_rand_02.txt AC 108 ms 5480 KiB
06_max_rand_03.txt AC 108 ms 5452 KiB
06_max_rand_04.txt AC 110 ms 5452 KiB
06_max_rand_05.txt AC 109 ms 5328 KiB
06_max_rand_06.txt AC 113 ms 5312 KiB
06_max_rand_07.txt AC 109 ms 5476 KiB
06_max_rand_08.txt AC 109 ms 5472 KiB
06_max_rand_09.txt AC 108 ms 5364 KiB
06_max_rand_10.txt AC 109 ms 5412 KiB
07_max_zero_01.txt AC 112 ms 5444 KiB
07_max_zero_02.txt AC 109 ms 5480 KiB
07_max_zero_03.txt AC 109 ms 5476 KiB
07_max_zero_04.txt AC 109 ms 5500 KiB
07_max_zero_05.txt AC 109 ms 5476 KiB
07_max_zero_06.txt AC 112 ms 5504 KiB
07_max_zero_07.txt AC 109 ms 5356 KiB
07_max_zero_08.txt AC 109 ms 5324 KiB
07_max_zero_09.txt AC 110 ms 5316 KiB
07_max_zero_10.txt AC 108 ms 5472 KiB
08_max_bracket_01.txt AC 68 ms 3768 KiB
08_max_bracket_02.txt AC 68 ms 3764 KiB
08_max_bracket_03.txt AC 67 ms 3788 KiB
08_max_bracket_04.txt AC 67 ms 3772 KiB
08_max_bracket_05.txt AC 66 ms 3780 KiB
08_max_bracket_06.txt AC 67 ms 3852 KiB
08_max_bracket_07.txt AC 70 ms 3588 KiB
08_max_bracket_08.txt AC 69 ms 3596 KiB
08_max_bracket_09.txt AC 66 ms 3848 KiB
08_max_bracket_10.txt AC 67 ms 3696 KiB
09_almost_same_01.txt AC 113 ms 5408 KiB
09_almost_same_02.txt AC 110 ms 5504 KiB
09_almost_same_03.txt AC 113 ms 5448 KiB
09_almost_same_04.txt AC 106 ms 5452 KiB
09_almost_same_05.txt AC 107 ms 5448 KiB
10_handmade_01.txt AC 106 ms 5480 KiB
10_handmade_02.txt AC 115 ms 5408 KiB
10_handmade_03.txt AC 67 ms 3876 KiB
10_handmade_04.txt AC 68 ms 3772 KiB
10_handmade_05.txt AC 65 ms 3784 KiB
10_handmade_06.txt AC 65 ms 3796 KiB