답안 #300712

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
300712 2020-09-17T12:33:45 Z Nodir_Bobiev Labels (NOI20_labels) C++17
0 / 100
51 ms 7672 KB
/*
+----------------------------------------------------------------+
| In the name of Allah, the most Gracious and the most Merciful. |
+----------------------------------------------------------------+
Our hearts quake with fear of you
Our hearts wake with love for you
And to Islam we must be true
In everything we think and do.
--------------------------------
When your heart is breaking
And your pain makes you fall
Remember just remember
Allah Sees it all.
*/
# include <bits/stdc++.h>
# define FILE
using namespace std;

int main(){
    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    int d[n] = {};
    for( int i = 1; i < n; i ++ ){
        cin >> d[i];
    }
    long long cnt[n] = {}, eq = 0, mx = 0, mn = 0, id = -1, val = -1;
    for( int i = 1; i < n; i ++ ){
        cnt[i] = d[i] + cnt[i-1];
        if( cnt[i] - mn == n-1 ){
            id = i;
            val = n;
            eq = 1;
        }
        if( cnt[i] - mx == -n+1 ){
            id = i;
            val = 1;
            eq = 1;
        }
        if( cnt[i] - mn > n-1 ){
            cout << -1; 
            return 0;
        }
        if( cnt[i] - mx == -n+1 ){
            cout << -1;
            return 0;
        }
        mx = max( mx, cnt[i] );
        mn = min( mn, cnt[i] );
    }
    if( !eq ) cout << -1;
    else{
        int a[n] = {};
        a[id] = val;
        for( int i = id+1; i < n; i ++ ){
            a[i] = a[i-1] + d[i];
        }
        for( int i = id-1; i >= 0; i -- ){
            a[i] = a[i+1] - d[i+1];
        }
        for( int i = 0; i < n; i ++ ){
            cout << a[i] << ' ';
        }cout << endl;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 640 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 640 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 640 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 51 ms 7672 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
3 Incorrect 29 ms 4736 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 640 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -