Submission #600191

# Submission time Handle Problem Language Result Execution time Memory
600191 2022-07-20T14:04:20 Z rajatshenoi Labels (NOI20_labels) C++14
7 / 100
76 ms 10184 KB
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
 
int main(int argc, char const *argv[])
{
	int N; cin >> N;
 
	vector<ll> v(N - 1, 0);
 
	if (N == 2)
    {
        int d;
        cin >> d;
        if (d == 0)
        {
            cout << "-1" << endl;
            return 0;
        }
        if (d == 1)
        {
            cout << "1 2" << endl;
            return 0;
        }
        if (d == -1)
        {
            cout << "2 1" << endl;
            return 0;
        }
    }

    for (int i = 0; i < N - 1; i++)
		cin >> v[i];

    vector<ll> temp(N, 0);
    temp[0] = 1;

    for (int i = 1; i < N; i++) {
    	temp[i] = temp[i - 1] + v[i - 1];
    }

    sort(temp.begin(), temp.end());

    ll sum = 2 - temp[0];

    vector<ll> out(N, 0);

    for (int i = 0; i < N - 1; i++) {
    	if (sum <= 0 || sum > N) {
    		cout << -1 << endl;
    		return 0;
    	} else {
    		out[i] = sum;
    		sum += v[i];
    	}
    }

    out[N - 1] = sum;

    for (auto el : out)
    	cout << el << " ";
    cout << endl;
 
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 71 ms 9796 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 76 ms 10184 KB Output is correct
4 Incorrect 62 ms 8524 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -