| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 1248610 | shirokito | Snail (NOI18_snail) | C++20 | 1 ms | 584 KiB | 
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 24;
const ll INF = 1e18;
ll n, h, a[N], pf[N];
void solve() {
    cin >> h >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        pf[i] = pf[i - 1] + a[i];
    }
    ll mn = INF, s = 0;
    for (int i = 1; i <= n; i++) {
        mn = min(mn, pf[i]);
        s = max(0LL, s + a[i]);
        if (s >= h) {
            cout << 0 << ' ' << i - 1 << '\n';
            return;
        }
    }
    pair<ll, ll> ans = {INF, INF};
    for (int i = 1; i <= n; i++) {
        if (pf[i] <= 0) continue;
        if (s + pf[i] >= h) {
            ans = min(ans, {1, i - 1});
        }
        else if (s + pf[i] <= 0) {
            cout << -1 << ' ' << -1 << '\n';
            return;
        }
        else if (pf[n] > 0) {
            ll k = (h - s - pf[i] + pf[n] - 1) / pf[n];
            ans = min(ans, {k + 1, i - 1});
        }
    }
    if (ans.first == INF) ans = {-1, -1};
    cout << ans.first << ' ' << ans.second << '\n';
}   
int main() {
    cin.tie(0) -> sync_with_stdio(0);
    #define task "file"
    if (fopen(task".inp", "r")) {
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    int T = 1; // cin >> T;
    while (T--) {
        solve();
    }
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
