|

General

# Author Problem Lang Verdict Time Memory Sent Judged
94144482 Practice:
Mooncrater
1329A - 22 GNU C++17 Accepted 62 ms 804 KB 2020-09-28 18:45:19 2020-09-28 18:45:19

→ Source
/*
"I will come again & conquer you
because as a mountain you can't grow, but as a human, I can.”
- Sir Edmund Hillary.
*/
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
typedef long double lld ;
#define f(i,s,n) for(int i=s;i<(int)n;i++)
#define fn(i,s,n) for(int i=s;i>=(int)n;i--)
template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }

#define vi vector<int>
#define vii vector<pair<int,int>>
#define vl vector<ll>
#define pb push_back
#define X first
#define Y second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define vll vector<pll>
#define fio ios::sync_with_stdio(0),cin.tie(0),cout.tie(0),cout<<setprecision(10) ;
#define is(x) cout<<#x<<" : "<<x<<endl ;
// const int MAXN = 2e5+5 ;
// const int MOD = 1e9+7 ;
// #define DEBUG

int main()
{
fio ;
/* ======================Start of code ================ */
int n,m;cin>>n>>m ;
ll total = 0 ;
vi v(m) ; f(i,0,m) cin>>v[i], total+=v[i] ;
if(total<n) return cout<<"-1\n",0 ;
vi ans(m) ;
f(i,0,m)
{
ans[i] = i ;
if(i+v[i]-1>=n) return cout<<"-1\n",0 ;
}
int last = n-1 ;
fn(i,m-1,0)
{
int currEnd = ans[i]+(v[i]-1) ;
if(last<=currEnd)
{
last = ans[i]-1 ;
continue ;
}
int gap = last-currEnd ;
ans[i] += gap ;
last = ans[i]-1 ;
}
for(auto x:ans) cout<<(x+1)<<" " ;
cout<<"\n" ;

/* ======================End of code ================== */
}

?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
?
?
?