답안 #337497

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
337497 2020-12-21T02:19:37 Z zapan4 Labels (NOI20_labels) C++17
25 / 100
218 ms 21228 KB
#include <iostream>
#include <cmath> 
#include <stdio.h>
#include <array>
#include <vector>
#include <list>
#include <algorithm>
#include <utility>
#include <string>
#include <sstream>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#define pp pair<int,int>
#define pll pair<ll, ll>
#define ll long long
using namespace std;

map<int, int> checking;
ll prefix[300001];
ll answers[300001];

int main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	ll n;
	cin >> n;
	ll maxi = 0;
	for (int i = 1; i < n; i++) {
		ll a;
		cin >> a;
		prefix[i] = prefix[i-1]+a;
		maxi = max(prefix[i], maxi);
	}
	int amount = n-maxi;
	answers[0] = amount;
	checking[amount] = 1;
	for (int i = 1; i < n; i++) {
		if (i == n-1) {
			if (checking.find(amount+prefix[i]) == checking.end()) {
				answers[i] = amount+prefix[i];
				checking[amount+prefix[i]] = 1;
			} else {
				cout << "-1" << endl;
				return 0;
			}
		} else {
			if (checking.find(amount+prefix[i]) == checking.end()) {
				answers[i] = amount+prefix[i];
				checking[amount+prefix[i]] = 1;
			} else {
				cout << "-1" << endl;
				return 0;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (i == 1) {
			cout << answers[i] << endl;
		} else {
	 		cout << answers[i] << " ";
	 	}
 	}

}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Incorrect 1 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Incorrect 1 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 188 ms 21116 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 218 ms 21228 KB Output is correct
4 Correct 51 ms 2668 KB Output is correct
5 Correct 59 ms 2612 KB Output is correct
6 Correct 59 ms 2668 KB Output is correct
7 Correct 52 ms 2668 KB Output is correct
8 Correct 74 ms 2668 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
5 Incorrect 1 ms 364 KB Output isn't correct
6 Halted 0 ms 0 KB -