답안 #1071514

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1071514 2024-08-23T08:00:22 Z zh_h Snail (NOI18_snail) C++17
0 / 100
1000 ms 604 KB
#include <bits/stdc++.h>
#define lint long long
#define pb push_back
#define mp make_pair
using namespace std;
lint MOD = 1e9 + 7;
int INF = 1e9;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    lint height, n;
    cin >> height >> n;

    //* while taking the input, find:
    //* 1. the average move per day
    //* 2. the highest that you can reach per day

    vector<lint> p;
    lint ave=0, highest=0, lowest=0;
    lint count=0;
    for(lint i = 0; i < n; i ++){
        lint temp;
        cin >> temp;
        p.pb(temp);

        count += temp;
        // if(count < 0){count = 0;}
        highest = max(highest, count);
        lowest = min(lowest, count);

        ave += temp;
    }

    // cout << highest << endl << lowest << endl;

    lowest *= -1;

    lint total = 0;
    lint days = 0;
    bool is_done = false;

    while(total < lowest && total < height){
        if(days > 1e3){is_done = true; cout << -1 << " " << -1; break;}
        // cout << days << " ";
        for(int i = 0; i < n; i ++){
            total += p[i];
            if(total < 0){total = 0;}
            if(total >= height){is_done = true; cout << days << " " << i; break;}
        }
        days++;
    }

    if(!is_done){
        while(total < height-highest){
            total += ave;
            days++;
        }
        
        for(int i = 0; i < n; i ++){
            total += p[i];
            if(total >= height){cout << days << " " << i;}
        }
    }

    return 0;
}

// 10 3
// 2 -10 8
// 1 0

// 5 1
// -1
// -1 -1

// 5 2
// 4 -2
// 1 0

// 3 1
// 1
// 2 0
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Execution timed out 1095 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1083 ms 604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1066 ms 604 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Execution timed out 1095 ms 348 KB Time limit exceeded
3 Halted 0 ms 0 KB -