제출 #516441

#제출 시각아이디문제언어결과실행 시간메모리
516441JomnoiLabels (NOI20_labels)C++17
100 / 100
72 ms5624 KiB
#include <bits/stdc++.h>
#define DEBUG 0
using namespace std;

const int N = 3e5 + 10;

int main() {
    int n;
    scanf(" %d", &n);
    vector <int> ans{0};
    int a = 0;
    int mn = 0, mx = 0;
    for(int i = 1; i < n; i++) {
        int d;
        scanf(" %d", &d);
        a += d;
        mn = min(mn, a);
        mx = max(mx, a);
        ans.push_back(a);
    }

    if(mx - mn != n - 1) {
        printf("-1");
        return 0;
    }
    for(auto v : ans) {
        printf("%d ", v - mn + 1);
    }
    return 0;
}

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

Labels.cpp: In function 'int main()':
Labels.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf(" %d", &n);
      |     ~~~~~^~~~~~~~~~~
Labels.cpp:15:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |         scanf(" %d", &d);
      |         ~~~~~^~~~~~~~~~~
#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...