| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1366352 | afterzero | Snail (NOI18_snail) | C++20 | 2 ms | 344 KiB |
#include<bits/stdc++.h>
using namespace std ;
int main(){
long long h , n ;
cin >> h>> n ;
vector<long long>a(n);
vector<long long> pref(n);
for(int i = 0 ; i< n ; i++){
cin >> a[i];
}
pref[0]=max(0LL,a[0]);
if(pref[0]>=h){cout << "0 0" ; return 0 ;}
for(int i = 1 ; i< n ; i++){
pref[i] = max(0LL ,pref[i-1] + a[i]);
if(pref[i]>=h){
cout << 0 << " " << i ;
return 0 ;
}
}
if(pref[n-1]<=0){
cout << "-1 -1";
return 0 ;
}
long long mx= *max_element(pref.begin(),pref.end());
long long days = (h - mx + pref[n-1] - 1) / pref[n-1];
long long cur = days * pref[n-1] ;
for(int i = 0 ; i< n ; i++){
cur = max(0LL , cur+a[i]);
if(cur>=h){
cout << days << " " << i ;
return 0 ;
}
}
}
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
