Submission #38016090


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

int a[200100];
long long s[200100];
long long now;

int main()
{
    int n;

    cin>>n;
    for(int i=1; i<=n; i++)
        scanf("%d", &a[i]);

    for(int i=n; i>=1; i--) s[i]=s[i+1]+a[i];
    for(int i=1; i<=n; i++) now+=a[i]*i;

    for(int i=1; i<=n; i++)
    if(s[i])
    {
        long long t=0,tnow=now;
        if(tnow>0&&s[i]>0)
        {
            if(!s[1]) continue;
            long long tmp=abs(s[1]);
            t=tnow/tmp; tnow%=tmp;
            if(tnow>0) ++t, tnow-=tmp;
            if(s[1]>0) t=-t;
        }
        if(tnow<0&&s[i]<0)
        {
            if(!s[1]) continue;
            long long tmp=abs(s[1]);
            tnow=-tnow;
            t=tnow/tmp; tnow%=tmp;
            if(tnow>0) ++t, tnow-=tmp;
            if(s[1]<0) t=-t;
            tnow=-tnow;
        }
        if(tnow%s[i]&&!s[1]) continue;
        long long ft=abs(tnow/s[i]); tnow%=s[i];
        if(tnow&&tnow%s[1]==0) t-=tnow/s[1];
        else if(tnow&&(s[i]+tnow)%s[1]==0)
        {
            ++ft;
            t-=(s[i]+tnow)/s[1];
        }
        else if(tnow) continue;
        puts("Yes");
        for(long long j=1; j<i; j++)
            printf("%lld ", j+t);
        for(long long j=i; j<=n; j++)
            printf("%lld ", j+t+ft);
        return 0;
    }
    puts("No");
    return 0;
}

Submission Info

Submission Time
Task C - ± Increasing Sequence
User LingChen
Language C++ (GCC 9.2.1)
Score 600
Code Size 1405 Byte
Status AC
Exec Time 48 ms
Memory 6160 KiB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   14 |         scanf("%d", &a[i]);
      |         ~~~~~^~~~~~~~~~~~~

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 3624 KiB
01_sample_02.txt AC 2 ms 3756 KiB
01_sample_03.txt AC 2 ms 3756 KiB
02_small_1_01.txt AC 2 ms 3796 KiB
02_small_1_02.txt AC 2 ms 3572 KiB
02_small_1_03.txt AC 2 ms 3620 KiB
02_small_1_04.txt AC 1 ms 3596 KiB
02_small_1_05.txt AC 2 ms 3488 KiB
02_small_1_06.txt AC 2 ms 3752 KiB
02_small_1_07.txt AC 2 ms 3704 KiB
02_small_1_08.txt AC 2 ms 3632 KiB
02_small_1_09.txt AC 2 ms 3752 KiB
02_small_1_10.txt AC 6 ms 3568 KiB
02_small_1_11.txt AC 2 ms 3612 KiB
02_small_1_12.txt AC 3 ms 3628 KiB
02_small_1_13.txt AC 2 ms 3752 KiB
02_small_1_14.txt AC 2 ms 3572 KiB
03_small_2_01.txt AC 2 ms 3696 KiB
03_small_2_02.txt AC 2 ms 3568 KiB
03_small_2_03.txt AC 2 ms 3628 KiB
03_small_2_04.txt AC 2 ms 3704 KiB
03_small_2_05.txt AC 2 ms 3576 KiB
03_small_2_06.txt AC 2 ms 3596 KiB
03_small_2_07.txt AC 2 ms 3704 KiB
03_small_2_08.txt AC 2 ms 3820 KiB
03_small_2_09.txt AC 3 ms 3572 KiB
03_small_2_10.txt AC 3 ms 3660 KiB
04_small_zero_01.txt AC 2 ms 3700 KiB
04_small_zero_02.txt AC 2 ms 3576 KiB
04_small_zero_03.txt AC 2 ms 3624 KiB
04_small_zero_04.txt AC 2 ms 3636 KiB
05_small_bracket_01.txt AC 2 ms 3632 KiB
05_small_bracket_02.txt AC 2 ms 3644 KiB
05_small_bracket_03.txt AC 2 ms 3756 KiB
05_small_bracket_04.txt AC 2 ms 3628 KiB
06_max_rand_01.txt AC 43 ms 5912 KiB
06_max_rand_02.txt AC 47 ms 6096 KiB
06_max_rand_03.txt AC 41 ms 6036 KiB
06_max_rand_04.txt AC 42 ms 6040 KiB
06_max_rand_05.txt AC 42 ms 6032 KiB
06_max_rand_06.txt AC 41 ms 5996 KiB
06_max_rand_07.txt AC 45 ms 6160 KiB
06_max_rand_08.txt AC 42 ms 6096 KiB
06_max_rand_09.txt AC 41 ms 6044 KiB
06_max_rand_10.txt AC 43 ms 6160 KiB
07_max_zero_01.txt AC 42 ms 6092 KiB
07_max_zero_02.txt AC 45 ms 6040 KiB
07_max_zero_03.txt AC 44 ms 6044 KiB
07_max_zero_04.txt AC 42 ms 5908 KiB
07_max_zero_05.txt AC 43 ms 6000 KiB
07_max_zero_06.txt AC 42 ms 5904 KiB
07_max_zero_07.txt AC 44 ms 6096 KiB
07_max_zero_08.txt AC 41 ms 6036 KiB
07_max_zero_09.txt AC 42 ms 6036 KiB
07_max_zero_10.txt AC 41 ms 6096 KiB
08_max_bracket_01.txt AC 28 ms 5852 KiB
08_max_bracket_02.txt AC 26 ms 5968 KiB
08_max_bracket_03.txt AC 22 ms 5972 KiB
08_max_bracket_04.txt AC 26 ms 5972 KiB
08_max_bracket_05.txt AC 27 ms 5968 KiB
08_max_bracket_06.txt AC 25 ms 5976 KiB
08_max_bracket_07.txt AC 24 ms 5968 KiB
08_max_bracket_08.txt AC 26 ms 6008 KiB
08_max_bracket_09.txt AC 25 ms 6096 KiB
08_max_bracket_10.txt AC 26 ms 5968 KiB
09_almost_same_01.txt AC 46 ms 6040 KiB
09_almost_same_02.txt AC 43 ms 5952 KiB
09_almost_same_03.txt AC 43 ms 6048 KiB
09_almost_same_04.txt AC 48 ms 6160 KiB
09_almost_same_05.txt AC 44 ms 6036 KiB
10_handmade_01.txt AC 44 ms 5916 KiB
10_handmade_02.txt AC 44 ms 6040 KiB
10_handmade_03.txt AC 21 ms 5824 KiB
10_handmade_04.txt AC 27 ms 5980 KiB
10_handmade_05.txt AC 28 ms 6096 KiB
10_handmade_06.txt AC 20 ms 5980 KiB