Submission #320533

# Submission time Handle Problem Language Result Execution time Memory
320533 2020-11-09T04:09:25 Z Sparky_09 Labels (NOI20_labels) C++17
0 / 100
3 ms 392 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
	ios_base::sync_with_stdio(false);
	freopen("input.txt", "r", stdin);
	int n;
	ll sum = 0, maxval = 0, minval = INT_MAX;
	cin >> n;
	vector<int> v(n), ans(n);
	for(int i = 0; i < n; i++){
	  cin >> v[i];
	  sum+=v[i];
	  maxval = max(maxval, sum);
	  minval = min(minval, sum);
	}
	ll idx = n-maxval;// cur = 0;
	bool notposs=0;
	if(maxval>=n){
	  notposs=1;
	}
	for(int i =  0; i < n and maxval<n; i++){
	  ans[i] = idx;
	  idx += v[i];
	  if(idx<=0){
	  	notposs=1;
	    break;
	  }
	}
	if(notposs or *min_element(ans.begin(), ans.end())!=1){
	  cout << -1 << '\n';
	}
	else{
	  for(auto i: ans){
	    cout << i << ' ';
	  }
	  cout << '\n';
	}
}


Compilation message

Labels.cpp: In function 'int main()':
Labels.cpp:7:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
    7 |  freopen("input.txt", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Incorrect 2 ms 392 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Incorrect 2 ms 392 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Incorrect 2 ms 392 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 364 KB Output is correct
2 Incorrect 2 ms 392 KB Output isn't correct
3 Halted 0 ms 0 KB -