제출 #969730

#제출 시각아이디문제언어결과실행 시간메모리
969730BestCrazyNoob모임들 (IOI18_meetings)C++17
0 / 100
5533 ms7368 KiB
#include "meetings.h" #include <vector> #include <algorithm> using namespace std; using ll = long long; constexpr int INF = 2e9; ll solve(vector<int> H) { vector<ll> ans(H.size(), 0); vector<int> s; int curr = 0; for (int i = 0; i < H.size(); i++) { while (s.size() >= 1 && H[i] > H[s.back()]) { const int d = s.size() == 1 ? s.back() + 1 : s.back() - s[s.size()-2]; curr += d * (H[i] - H[s.back()]); s.pop_back(); } s.push_back(i); curr += H[i]; ans[i] = curr; } curr = 0; s.resize(0); for (int i = H.size()-1; i >= 0; i--) { while (s.size() >= 1 && H[i] > H[s.back()]) { const int d = s.size() == 1 ? H.size() - s.back() : s[s.size()-2] - s.back(); curr += d * (H[i] - H[s.back()]); s.pop_back(); } s.push_back(i); ans[i] += curr; curr += H[i]; } return *min_element(ans.begin(), ans.end()); } vector<long long> minimum_costs(vector<int> H, vector<int> L, vector<int> R) { vector<ll> C(L.size()); for (int q = 0; q < L.size(); q++) { C[q] = solve(vector<int>(H.begin() + L[q], H.begin() + R[q] + 1)); } return C; }

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

meetings.cpp: In function 'll solve(std::vector<int>)':
meetings.cpp:13:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for (int i = 0; i < H.size(); i++) {
      |                     ~~^~~~~~~~~~
meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:40:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for (int q = 0; q < L.size(); q++) {
      |                     ~~^~~~~~~~~~
#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...