답안 #383321

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
383321 2021-03-29T15:22:42 Z MODDI Labels (NOI20_labels) C++14
7 / 100
110 ms 6876 KB
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define mp make_pair
#define pb push_back
using namespace std;
int main(){
	int n;
	cin>>n;
	vi d;
	for(int i = 0; i < n-1; i++){
		int a;
		cin>>a;
		d.pb(a);
	}
	if(n == 2 && d[0]==0){
		cout<<-1<<endl;
		return 0;
	}
	vi cur, rez;
	int sols = 0;
	cur.pb(1);
	bool valid = true;
	for(int j = 0; j <n-1;j++){
		if(d[j] + cur[cur.size()-1] <=n && d[j]+cur[cur.size()-1] >0)
			cur.pb(d[j] + cur[cur.size()-1]);
		else{
			valid = false;
		}
	}
	if(valid){
		sols++;
		rez = cur;
		}
		
	cur.clear();
	valid = true;
	cur.pb(n);
	for(int j = 0; j <n-1;j++){
		if(d[j] + cur[cur.size()-1] <=n && d[j]+cur[cur.size()-1] >0)
			cur.pb(d[j] + cur[cur.size()-1]);
		else{
			valid = false;
		}
	}
	if(valid){
		sols++;
		rez = cur;
		}
	
	cur.pb(n);
	if(sols == 1){
		for(int i = 0; i < (int)rez.size(); i++)
			cout<<rez[i]<<" ";
	}
	else
		cout<<-1<<endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 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 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 97 ms 5980 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 110 ms 6876 KB Output is correct
4 Correct 59 ms 5232 KB Output is correct
5 Correct 66 ms 5340 KB Output is correct
6 Incorrect 108 ms 6876 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Incorrect 1 ms 364 KB Output isn't correct
5 Halted 0 ms 0 KB -