# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
320462 | egas | Labels (NOI20_labels) | C++14 | 271 ms | 29016 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
long long n;
cin >> n;
vector<long long> a(n-1);
for(long long i = 0 ; i < n-1 ; i++) {
cin >> a[i];
}
vector<long long> pref;
pref.push_back(a[0]);
for(long long i=1; i<n-1; i++) {
pref.push_back(pref.back()+a[i]);
}
long long maxi = *max_element(pref.begin(),pref.end());
long long mini = *max_element(pref.begin(),pref.end());
long long xo=min(n,n-maxi);
bool hoga=true;
if(maxi+xo<1 or maxi+xo>n or mini+xo<1 or mini+xo>n)
hoga=false;
vector<long long> res;
res.push_back(xo);
map<long long,long long> freq;
freq[xo]=1;
for(long long i=0; i<n-1; i++) {
res.push_back(res.back()+a[i]);
freq[res.back()]++;
}
if(freq[1]==0 or freq[n]==0)hoga=false;
for(long long i = 0 ; i < res.size() ; i++) {
if(res[i]<1 or res[i]>n)hoga=false;
}
if(hoga) {
for(auto t : res )cout<<t<<" ";
cout << '\n';
} else {
cout << -1 << '\n';
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |