제출 #1366358

#제출 시각아이디문제언어결과실행 시간메모리
1366358afterzeroSnail (NOI18_snail)C++20
37 / 100
2 ms344 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);
    long long total_p = 0, max_p = -2e18, current_p = 0;

    for (int i = 0; i < n; i++) {
        cin >> p[i];
        current_p += p[i];
        max_p = max(max_p, current_p);
        total_p += p[i];
    }

  
    long long cur = 0;
    for (int i = 0; i < n; i++) {
        cur = max(0LL, cur + p[i]);
        if (cur >= h) { cout << "0 " << i << endl; return 0; }
    }

    if (total_p <= 0) { cout << "-1 -1" << endl; return 0; }

    
    long long days = (h - max_p - cur + total_p - 1) / total_p;
    cur += days * total_p;
    days += 1; 

    for (int i = 0; i < n; i++) {
        cur = max(0LL, cur + p[i]);
        if (cur >= h) { cout << days << " " << i << endl; return 0; }
    }

    return 0;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…