Submission #1090065

# Submission time Handle Problem Language Result Execution time Memory
1090065 2024-09-17T16:41:13 Z dpsaveslives Snail (NOI18_snail) C++17
37 / 100
2 ms 692 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll H; int N; cin >> H >> N;
    vector<ll> phases(N);
    vector<ll> pref(N);
    for(int i = 0;i<N;++i){
        cin >> phases[i];
        if(i == 0) pref[i] = max(0ll,phases[i]);
        else pref[i] = max(0ll,phases[i]+pref[i-1]);
    }
    if(pref[N-1] == 0){
        for(int i = 0;i<N;++i){
            if(pref[i] >= H){
                cout << 0 << " " << i << "\n";
                return 0;
            }
        }
        cout << -1 << " " << -1 << "\n";
        return 0;
    }
    ll ans = -1, p = -1;
    for(int i = 0;i<N;++i){
        ll cur = H-pref[i];
        if(cur <= 0){
            if(ans == -1 || 0 < ans){
                ans = 0;
                p = i;
            }
            continue;
        }
        ll d = cur/pref[N-1];
        if(cur % pref[N-1] != 0){
            ++d;
        }
        if(ans == -1 || d < ans){
            ans = d;
            p = i;
        }
    }
    cout << ans << " " << p << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 352 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 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 -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 640 KB Output is correct
6 Correct 1 ms 692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 352 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 1 ms 608 KB Output is correct
14 Correct 1 ms 600 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Incorrect 0 ms 348 KB Output isn't correct
17 Halted 0 ms 0 KB -