제출 #1062492

#제출 시각아이디문제언어결과실행 시간메모리
1062492zh_hSnail (NOI18_snail)C++17
0 / 100
1 ms604 KiB
#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 h, p; cin >> h >> p; vector<lint> v; lint sum = 0; for(lint i = 0; i < p; i ++){ lint temp; cin >> temp; v.pb(temp); sum += temp; } if(sum < 0){cout << -1 << " " << -1;} else if(sum == 0){ lint h1 = 0; lint is_valid = -1; for(lint i = 0; i < p; i ++){ if(h1 >= h){is_valid = i; break;} h1+=v[i]; if(h1 < 0){h1 = 0;} } if(is_valid != -1){cout << 0 << " " << is_valid;} else cout << -1 << " " << -1; } else{ lint m = 0; lint temp = 0; for(lint i = 0; i < p; i ++){ temp += v[i]; m = max(m, temp); } if(m >= h){ lint h1 = 0; lint is_valid = -1; for(lint i = 0; i < p; i ++){ if(h1 >= h){is_valid = i; break;} h1+=v[i]; if(h1 < 0){h1 = 0;} } cout << 0 << " " << is_valid; } else{ lint days = (h-m+sum-1)/sum; lint thatday = days*sum; lint valid; while(thatday >= h){thatday-=sum; days--;} while(thatday + m < h){thatday += sum; days++;} for(lint i = 0; i < p; i ++){ thatday += v[i]; if(thatday >= h){valid = i; break;} } cout << days << " " << valid; } } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...