제출 #710636

#제출 시각아이디문제언어결과실행 시간메모리
710636Cyanmond모임들 (IOI18_meetings)C++17
0 / 100
1 ms212 KiB
#include "meetings.h" #include <bits/stdc++.h> using i64 = long long; constexpr i64 inf = 1ll << 50; std::vector<i64> solve(const std::vector<i64> &H) { const int N = (int)H.size(); std::vector<i64> valList(N); std::stack<std::pair<int, i64>> stk; i64 sum = 0; for (int i = 0; i < N; ++i) { // update int u = 1; while ((not stk.empty()) and (stk.top().second <= H[i])) { sum -= stk.top().second * stk.top().first; u += stk.top().first; stk.pop(); } stk.push({u, H[i]}); sum += u * H[i]; valList[i] = sum; } return valList; } std::vector<long long> minimum_costs(std::vector<int> H, std::vector<int> L, std::vector<int> R) { int N = (int)H.size(), Q = (int)L.size(); std::vector<i64> answer(Q); for (int i = 0; i < Q; ++i) { std::vector<i64> h(R[i] - L[i] + 1); for (int j = L[i]; j <= R[i]; ++j) h[j - L[i]] = H[j]; const auto x = solve(h); std::reverse(h.begin(), h.end()); const auto y = solve(h); i64 res = inf; for (int j = 0; j < (R[i] - L[i] + 1); ++j) { res = std::min(res, x[j] + y[j]); } answer[i] = res; } return answer; }

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

meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:29:9: warning: unused variable 'N' [-Wunused-variable]
   29 |     int N = (int)H.size(), Q = (int)L.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...