답안 #979469

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
979469 2024-05-11T05:03:40 Z michified Lightning Conductor (POI11_pio) C++17
45 / 100
632 ms 12196 KB
#include <bits/stdc++.h>
using namespace std;

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

    int n, i, cur = 0;
    cin >> n;
    vector<int> h(n), ans(n);
    for (i = 0; i < n; i++) cin >> h[i];

    vector<int> hull = {0};
    for (i = 1; i < n; i++) {
        if (h[i] > h[hull.back()]) hull.push_back(i);
    }
    for (i = 0; i < n; i++) {
        while (cur < hull.size() - 1 and hull[cur] < i and h[hull[cur]] + sqrt(i - hull[cur]) < h[hull[cur + 1]] + sqrt(i - hull[cur + 1])) cur++;
        ans[i] = max(ans[i], (int) ceil(h[hull[cur]] + sqrt(i - hull[cur]) - 1e-8));
    }

    reverse(h.begin(), h.end());
    reverse(ans.begin(), ans.end());
    hull = {0};
    for (i = 1; i < n; i++) {
        if (h[i] > h[hull.back()]) hull.push_back(i);
    }
    cur = 0;
    for (i = 0; i < n; i++) {
        while (cur < hull.size() - 1 and hull[cur] < i and h[hull[cur]] + sqrt(i - hull[cur]) < h[hull[cur + 1]] + sqrt(i - hull[cur + 1])) cur++;
        ans[i] = max(ans[i], (int) ceil(h[hull[cur]] + sqrt(i - hull[cur]) - 1e-8));
    }

    reverse(ans.begin(), ans.end());
    reverse(h.begin(), h.end());
    for (i = 0; i < n; i++) cout << max(0, ans[i] - h[i]) << endl;
    return 0;
}

Compilation message

pio.cpp: In function 'int main()':
pio.cpp:18:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         while (cur < hull.size() - 1 and hull[cur] < i and h[hull[cur]] + sqrt(i - hull[cur]) < h[hull[cur + 1]] + sqrt(i - hull[cur + 1])) cur++;
      |                ~~~~^~~~~~~~~~~~~~~~~
pio.cpp:30:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         while (cur < hull.size() - 1 and hull[cur] < i and h[hull[cur]] + sqrt(i - hull[cur]) < h[hull[cur + 1]] + sqrt(i - hull[cur + 1])) cur++;
      |                ~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 1252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 67 ms 1736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 1524 KB Output is correct
2 Correct 74 ms 1112 KB Output is correct
3 Incorrect 78 ms 1620 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 118 ms 2380 KB Output is correct
2 Correct 120 ms 2128 KB Output is correct
3 Incorrect 118 ms 2640 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 274 ms 4376 KB Output is correct
2 Correct 277 ms 4692 KB Output is correct
3 Incorrect 272 ms 4692 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 438 ms 8888 KB Output is correct
2 Correct 416 ms 6544 KB Output is correct
3 Incorrect 416 ms 7964 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 613 ms 12196 KB Output is correct
2 Correct 608 ms 9384 KB Output is correct
3 Incorrect 596 ms 11092 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 610 ms 9280 KB Output is correct
2 Correct 632 ms 8972 KB Output is correct
3 Incorrect 597 ms 11148 KB Output isn't correct
4 Halted 0 ms 0 KB -