#include <bits/stdc++.h>
#include <chrono>
#define ll long long int
#define endl '\n'
#define vn vector<ll>
#define vi vector<pair <ll,ll>>
using namespace std;
using namespace std::chrono;
const int MAX_N = 1e9 + 7;
#define pii pair<ll,ll>
const ll INF = 0x3f3f3f3f3f3f3f3f;
#define pb push_back
#define srt(vp) sort(vp.begin(), vp.end())
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
auto start = high_resolution_clock::now();
ll h,n;
cin>>h>>n;
vn v(n);
for (auto &x:v)cin>>x;
vn pos(n);
pos[0]=max(0LL,0+v[0]);
for (int i=1;i<n;i++){
pos[i]=max(0LL,pos[i-1]+v[i]);
}
if (pos[n-1]==0)cout<<-1<<" "<<-1<<endl;
else{
ll curr = 0;
ll days = 0;
ll phase ;
while (curr <= h){
if (curr + pos[n-1]<h){
days++;
curr += pos[n-1];
}
else{
ll rem = h - curr;
auto it = upper_bound(pos.begin(),pos.end(),h);
phase += *it;
phase = it-pos.begin();
phase--;
break;
}
}
cout<<days<<" "<<phase<<endl;
}
auto stop = high_resolution_clock::now();
auto duration = duration_cast<microseconds>(stop - start);
//cout << "Time taken by function: " << duration.count() << " microseconds" << endl;
return 0;
}
# | 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... |