Submission #730044

#TimeUsernameProblemLanguageResultExecution timeMemory
730044t6twotwo모임들 (IOI18_meetings)C++17
19 / 100
473 ms196500 KiB
#include "meetings.h" #include <bits/stdc++.h> using namespace std; using ll = long long; const ll inf = 1E18; vector<ll> minimum_costs(vector<int> H, vector<int> L, vector<int> R) { int N = H.size(); int Q = L.size(); if (N <= 5000 && Q <= 5000) { vector pfs(N, vector<ll>(N + 1)); for (int i = 0; i < N; i++) { vector<int> mx(N); mx[i] = H[i]; for (int j = i - 1; j >= 0; j--) { mx[j] = max(mx[j + 1], H[j]); } for (int j = i + 1; j < N; j++) { mx[j] = max(mx[j - 1], H[j]); } for (int j = 0; j < N; j++) { pfs[i][j + 1] = pfs[i][j] + mx[j]; } } vector<ll> ans(Q, inf); for (int i = 0; i < Q; i++) { for (int j = L[i]; j <= R[i]; j++) { ans[i] = min(ans[i], pfs[j][R[i] + 1] - pfs[j][L[i]]); } } return ans; } else { vector<int> two; for (int i = 0; i < N; i++) { if (H[i] == 2) { two.push_back(i); } } vector<ll> ans(Q, inf); for (int i = 0; i < Q; i++) { int x = lower_bound(two.begin(), two.end(), L[i]) - two.begin(); int y = upper_bound(two.begin(), two.end(), R[i]) - two.begin() - 1; if (x == two.size() || two[x] > R[i]) { ans[i] = R[i] - L[i] + 1; } else { ans[i] = R[i] - L[i] + 1 + two[y] - two[x] + 1; } } return ans; } }

Compilation message (stderr)

meetings.cpp: In function 'std::vector<long long int> minimum_costs(std::vector<int>, std::vector<int>, std::vector<int>)':
meetings.cpp:42:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |             if (x == two.size() || two[x] > R[i]) {
      |                 ~~^~~~~~~~~~~~~
#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...