답안 #301169

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
301169 2020-09-17T17:14:02 Z beso123 Labels (NOI20_labels) C++14
0 / 100
36 ms 1664 KB
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define x first
#define y second
using namespace std;
int n;
int a[100005];
main(){
cin>>n;
a[1]=1;
for(int k=2;k<=n;k++){
    cin>>a[k];
    a[k]+=a[k-1];
}
int ad=0;
for(int k=1;k<=n;k++){
        if(a[k]<0)
    ad=max(ad,abs(a[k]));
}
for(int k=1;k<=n;k++)
    a[k]+=ad;
    int mx=0;
for(int k=1;k<=n;k++){
    mx=max(mx,a[k]);
}
if(mx!=n)
    cout<<-1;
else{
    for(int k=1;k<=n;k++)
        cout<<a[k]<<' ';
}
return 0;
}

Compilation message

Labels.cpp:9:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main(){
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 36 ms 1664 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -