Submission #1366354

#TimeUsernameProblemLanguageResultExecution timeMemory
1366354afterzeroSnail (NOI18_snail)C++20
37 / 100
2 ms492 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    long long H;
    int N;
    cin >> H >> N;
    vector<long long> P(N);
    for (int i = 0; i < N; i++) cin >> P[i];

    
    long long current_h = 0;
    long long max_reach = 0;
    for (int i = 0; i < N; i++) {
        current_h = max(0LL, current_h + P[i]);
        max_reach = max(max_reach, current_h);
        if (current_h >= H) {
            cout << 0 << " " << i << endl;
            return 0;
        }
    }

    long long day_gain = current_h;
    if (day_gain <= 0) {
        cout << "-1 -1" << endl;
        return 0;
    }

  
    long long skip_days = (H - max_reach + day_gain - 1) / day_gain;
    current_h = skip_days * day_gain;

  
    for (int i = 0; i < N; i++) {
        current_h = max(0LL, current_h + P[i]);
        if (current_h >= H) {
            cout << skip_days << " " << i << endl;
            return 0;
        }
    }

    return 0;
}
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...
#Result Execution timeMemoryGrader output
Fetching results...