답안 #1090610

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1090610 2024-09-18T14:05:15 Z dpsaveslives Snail (NOI18_snail) C++17
0 / 100
1 ms 456 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,N; cin >> H >> N;
    vector<ll> phases(N); ll day0 = 0, sec = 0;
    for(int i = 0;i<N;++i){
        cin >> phases[i];
        sec += phases[i];
        day0 += phases[i];
        day0 = max(day0,0ll);
    }
    ll cur = 0;
    for(int i = 0;i<2;++i){
        for(int j = 0;j<N;++j){
            cur += phases[j];
            cur = max(cur,0ll);
            if(cur >= H){
                cout << i << " " << j << "\n";
                return 0;
            }
        }
    }
    if(sec <= 0){
        cout << -1 << " " << -1 << "\n";
    }
    else{
        ll best = 0; cur = 0;
        for(int i = 0;i<N;++i){
            cur += phases[i];
            best = max(best,cur);
        }
        best -= day0;
        ll maxn = (H-best-day0+sec-1)/sec;
        cur = maxn*sec+day0;
        for(int i = 0;i<N;++i){
            cur += phases[i];
            if(cur >= H){
                cout << maxn+1 << " " << i << "\n";
                return 0;
            }
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 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 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 0 ms 456 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Incorrect 0 ms 348 KB Output isn't correct
5 Halted 0 ms 0 KB -