Submission #483995

#TimeUsernameProblemLanguageResultExecution timeMemory
483995T0p_Labels (NOI20_labels)C++14
100 / 100
70 ms5476 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = 3e5+5;
int d[N];

int main()
{
    int n;
    scanf(" %d",&n);
    int mn = 1e9, mx = -1e9;
    for(int i=2 ; i<=n ; i++)
    {
        scanf(" %lld",&d[i]);
        d[i] += d[i-1];
        mn = min(mn, d[i]);
        mx = max(mx, d[i]);
    }
    int cnt = 0;
    for(int a1=1 ; a1<=n ; a1++) if(1 <= a1+mn && a1+mn <= n && 1 <= a1+mx && a1+mx <= n) cnt++;
    if(cnt != 1) printf("-1\n");
    else
    {
        for(int a1=1 ; a1<=n ; a1++) if(1 <= a1+mn && a1+mn <= n && 1 <= a1+mx && a1+mx <= n)
        {
            printf("%d ",a1);
            for(int i=2 ; i<=n ; i++) printf("%d ",a1+d[i]);
            return 0;
        }
    }
    return 0;
}

Compilation message (stderr)

Labels.cpp: In function 'int main()':
Labels.cpp:14:20: warning: format '%lld' expects argument of type 'long long int*', but argument 2 has type 'int*' [-Wformat=]
   14 |         scanf(" %lld",&d[i]);
      |                 ~~~^  ~~~~~
      |                    |  |
      |                    |  int*
      |                    long long int*
      |                 %d
Labels.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf(" %d",&n);
      |     ~~~~~^~~~~~~~~~
Labels.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |         scanf(" %lld",&d[i]);
      |         ~~~~~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...