답안 #1091680

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1091680 2024-09-21T19:39:38 Z svm Snail (NOI18_snail) C++14
0 / 100
2 ms 604 KB
#include <bits/stdc++.h>

#define TASK "snail"

using namespace std;

#define fst first
#define snd second

typedef long long int64;
typedef pair<int, int> pii;

int64 rdiv(int64 a, int64 b) {
    if (a <= 0) return 0;
    return (a + b - 1)/ b;
}

int main() {
    #ifndef ONLINE_JUDGE
    freopen(TASK".inp", "r", stdin);
    freopen(TASK".out", "w", stdout);
    #endif
    cin.tie(0)->sync_with_stdio(false);
    int64 h; int n;
    cin >> h >> n;
    vector<int64> p (n + 5);
    int64 sum_p = 0, max_p = 0;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        sum_p += p[i];
        max_p = max(max_p, sum_p);
    }
    if (sum_p <= 0) {
        cout << "-1 -1\n";
        return 0;
    }
    int64 day = rdiv(h - max_p, sum_p);
    int64 curr_height = day * sum_p;
    if (curr_height >= h) {
        cout << day - 1 << ' ' << n - 1 << '\n';
        return 0;
    }
    for (int i = 0; i < n; i++) {
        curr_height += p[i];
        if (curr_height >= h) {
            cout << day << ' ' << i << '\n';
            return 0;
        }
    }
}

Compilation message

snail.cpp: In function 'int main()':
snail.cpp:20:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |     freopen(TASK".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
snail.cpp:21:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     freopen(TASK".out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -