General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
75413150 Contestant:
TYGL
1330C - 13 GNU C++11 Wrong answer on pretest 5 31 ms 408 KB 2020-04-03 19:32:58 2020-04-03 19:32:58
 
 
→ Source
#include <bits/stdc++.h>

using namespace std;

#define il inline
#define re register
#define Rep(i, s, e) for (re int i = s; i <= e; ++i)
#define Dep(i, s, e) for (re int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)

const int N = 100010;

il int read() {
    int x = 0; bool f = true; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = false; c = getchar();}
    while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return f ? x : -x;
}

int n, m;
int l[N];

int main() {
    n = read(), m = read();
    Rep(i, 1, m) l[i] = read();
    int sum = 0;
    Rep(i, 1, m) {
        if (l[i] > n - i + 1) return puts("-1") & 0;
        if (sum < n) sum += l[i];
    }
    if (sum < n) return puts("-1") & 0;
    int pos = 0; bool flag = false;
    Rep(i, 1, m) {
    	if (flag) {
    		printf("%d ", ++pos);
    		continue;
		}
    	int tp = n - pos - m + i - l[m] + 1;
    	if (l[i] >= tp) {
    		flag = true;
    		printf("%d ", pos + 1), pos += tp;
		}
		else printf("%d ", pos + 1), pos += l[i];
	}
    return 0;
}
 
 
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details