Submission #1090023

# Submission time Handle Problem Language Result Execution time Memory
1090023 2024-09-17T15:07:08 Z dpsaveslives Snail (NOI18_snail) C++17
0 / 100
1 ms 860 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] = phases[i];
        else pref[i] = phases[i]+pref[i-1];
    }
    ll ans = -1, p = -1;
    ll d = H/pref[N-1];
    if(H % pref[N-1] != 0) ++d;
    if(d >= 0){
        ans = d;
        p = 0;
    }
    for(int i = 0;i<N;++i){
        ll cur = H-pref[i];
        d = cur/pref[N-1];
        if(d < 0) continue;
        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 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 860 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -