제출 #344869

#제출 시각아이디문제언어결과실행 시간메모리
344869Jarif_RahmanLabels (NOI20_labels)C++17
100 / 100
74 ms6892 KiB
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n; cin >> n;
    vector<int> v(n-1);
    for(int &x: v) cin >> x;
    int mx = 0, mn = 1e8;
    int cur = 0;
    for(int i = 0; i < n-1; i++) cur+=v[i], mx = max(mx, cur), mn = min(mn, cur);
    bool bl = 1;
    int c = n - mx;
    vector<int> ans(n);
    ans[0] = c;
    for(int i = 1; i < n; i++) ans[i] = ans[i-1] + v[i-1];
    bool o = 0, nn = 0;
    for(int i = 0; i < n; i++){
        if(ans[i] == 1) o = 1;
        if(ans[i] == n) nn = 1;
    }
    if(!o || !nn){
        cout << "-1\n";
        exit(0);
    }
    for(int x: ans) cout << x << " ";
    cout << "\n";
}

컴파일 시 표준 에러 (stderr) 메시지

Labels.cpp: In function 'int main()':
Labels.cpp:17:10: warning: unused variable 'bl' [-Wunused-variable]
   17 |     bool bl = 1;
      |          ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...