제출 #1191560

#제출 시각아이디문제언어결과실행 시간메모리
1191560avighnaSnail (NOI18_snail)C++20
0 / 100
1 ms328 KiB
#include <bits/stdc++.h> int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); int64_t h, sum = 0; std::pair<int64_t, int> max_sum = {-1, -1}; int n; std::cin >> h >> n; std::vector<int64_t> p(n); for (int i = 0; i < n; ++i) { std::cin >> p[i]; sum += p[i]; max_sum = std::max(max_sum, {sum, i}); } if (sum < 0) { if (max_sum.first >= h) { std::cout << "0 " << max_sum.second << '\n'; } else { std::cout << "-1 -1\n"; } return 0; } int64_t day = (h - max_sum.first + sum - 1) / sum; int64_t cur_pos = sum * day; for (int i = 0; i < n; ++i) { cur_pos += p[i]; if (cur_pos >= h) { std::cout << day << ' ' << i << '\n'; 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...