Submission #1028365

# Submission time Handle Problem Language Result Execution time Memory
1028365 2024-07-19T17:33:02 Z Swee Pilot (NOI19_pilot) C++14
0 / 100
216 ms 11224 KB
#include <iostream>
#include <vector>

using namespace std;

struct mountain {
    int height;
    int index;
};

vector<long long> count(vector<int> h, vector<int> y) {
    h.push_back(1000001); // last border

    vector<mountain> border(10000);
    border[0] = {1000002, -1}; // blocker

    vector<long long> allPlanes(1000001);
    for (int i = 0; i < h.size(); i++) {
        for (;h[i] >= border.back().height; border.pop_back()) { // remove last border
            long long a = (i - border.back().index), b = (border.back().index - border[border.size() - 2].index);
            allPlanes[border.back().height] += a * b; // add possible flights to last border mountain height velocity plane
            // starting before or with last border * ending after or with last border
        }
        border.push_back({h[i], i}); // add border
    }

    for (int i = 2; i < allPlanes.size(); i++) { // partial sum of possible flights
        allPlanes[i] += allPlanes[i - 1];
    }

    vector<long long> result(y.size());

    for (int Y : y) { // filling up queries
        if (Y >= allPlanes.size()) {
            result.push_back(allPlanes.back());
        }else {
            result.push_back(allPlanes[Y]);
        }
    }

    return result;
}

int main() {
    int n, q;
    cin >> n >> q;

    vector<int> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    vector<int> y(q);
    for (int i = 0; i < q; i++) {
        cin >> y[i];
    }

    for (long long r : count(h, y)) {
        cout << r << endl;
    }

    return 0;
}

Compilation message

pilot.cpp: In function 'std::vector<long long int> count(std::vector<int>, std::vector<int>)':
pilot.cpp:18:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for (int i = 0; i < h.size(); i++) {
      |                     ~~^~~~~~~~~~
pilot.cpp:27:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for (int i = 2; i < allPlanes.size(); i++) { // partial sum of possible flights
      |                     ~~^~~~~~~~~~~~~~~~~~
pilot.cpp:34:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |         if (Y >= allPlanes.size()) {
      |             ~~^~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 8924 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 216 ms 11184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 213 ms 11224 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8280 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 8280 KB Output isn't correct
2 Halted 0 ms 0 KB -