#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll N=100005;
ll h, n, i, j, a[N], pha_max, x;
int main(){
// freopen("snail.inp","r",stdin);
//freopen("snail.out","w",stdout);
cin>>h>>n;
for(i=1; i<=n; i++){
cin>>a[i];
a[i]=a[i-1]+a[i];
pha_max=max(pha_max, a[i]);
}
if(pha_max<h){
if(a[n]<=0){
cout<<-1<<' '<<-1;
return 0;
}
}
x=(h-pha_max)/a[n];
x--;
x=max(x, 0LL);
while(true){
if(pha_max+x*a[n]>=h){
for(i=1; i<=n; i++){
if(x*a[n]+a[i]>=h){
cout<<x<<' '<<i-1;
return 0;
}
}
}
x++;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |