답안 #979473

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

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

    int n, i, cur = 0, at = 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++) {
        if (at < hull.size() - 1 and hull[at + 1] == i) at++;
        while (cur < hull.size() - 1 and hull[cur] < i and h[hull[cur]] + sqrt(i - hull[cur]) < h[hull[at]] + sqrt(i - hull[at])) cur = at;
        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, at = 0;
    for (i = 0; i < n; i++) {
        if (at < hull.size() - 1 and hull[at + 1] == i) at++;
        while (cur < hull.size() - 1 and hull[cur] < i and h[hull[cur]] + sqrt(i - hull[cur]) < h[hull[at]] + sqrt(i - hull[at])) cur = at;
        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:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         if (at < hull.size() - 1 and hull[at + 1] == i) at++;
      |             ~~~^~~~~~~~~~~~~~~~~
pio.cpp:19:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |         while (cur < hull.size() - 1 and hull[cur] < i and h[hull[cur]] + sqrt(i - hull[cur]) < h[hull[at]] + sqrt(i - hull[at])) cur = at;
      |                ~~~~^~~~~~~~~~~~~~~~~
pio.cpp:31:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         if (at < hull.size() - 1 and hull[at + 1] == i) at++;
      |             ~~~^~~~~~~~~~~~~~~~~
pio.cpp:32:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         while (cur < hull.size() - 1 and hull[cur] < i and h[hull[cur]] + sqrt(i - hull[cur]) < h[hull[at]] + sqrt(i - hull[at])) cur = at;
      |                ~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 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 37 ms 880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 62 ms 1292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 83 ms 1232 KB Output is correct
2 Correct 75 ms 1116 KB Output is correct
3 Incorrect 78 ms 1460 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 117 ms 1616 KB Output is correct
2 Correct 123 ms 1580 KB Output is correct
3 Incorrect 117 ms 2124 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 272 ms 3156 KB Output is correct
2 Correct 281 ms 3020 KB Output is correct
3 Incorrect 269 ms 3692 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 441 ms 6456 KB Output is correct
2 Correct 421 ms 4436 KB Output is correct
3 Incorrect 422 ms 6480 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 623 ms 9204 KB Output is correct
2 Correct 612 ms 6220 KB Output is correct
3 Incorrect 605 ms 9324 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 601 ms 7008 KB Output isn't correct
2 Halted 0 ms 0 KB -