제출 #1028345

#제출 시각아이디문제언어결과실행 시간메모리
1028345SweePilot (NOI19_pilot)C++14
89 / 100
1055 ms48648 KiB
#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; border.push_back({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; 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; }

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...