#include <bits/stdc++.h>
#define lint long long
#define pb push_back
#define mp make_pair
using namespace std;
lint MOD = 1e9 + 7;
int INF = 1e9;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
lint height, n;
cin >> height >> n;
//* while taking the input, find:
//* 1. the average move per day
//* 2. the highest that you can reach per day
//* (and also which phase does it reach the highest)
vector<int> p;
lint ave=0, highest=0, phase_highest;
lint count = 0;
for(int i = 0; i < n; i ++){
int temp;
cin >> temp;
p.pb(temp);
count += temp;
if(count > highest){
highest = count;
phase_highest = i;
}
ave += temp;
}
if(highest > height){
cout << 0 << " " << phase_highest;
}
else if(ave <= 0){
cout << -1 << " " << -1;
}
else{
//* after N days
//* at the N+1_th days, the snail reach the highest at some moment
//* so basically, N*ave < height, N*ave + highest >= height
//* search the N+1_th day
//* first step: find smallest N such that N*ave >= height - highest
//* can use binary search
//* or just MATH
lint N;
//*ceil((height - highest)/ave;
N = (height - highest + ave - 1) / ave;
lint total = N*ave;
for(int i = 0; i < n; i ++){
total += p[i];
if(total >= height){
cout << N << " " << i;
break;
}
}
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |