제출 #991882

#제출 시각아이디문제언어결과실행 시간메모리
991882crafticatCloud Computing (CEOI18_clo)C++17
0 / 100
137 ms262144 KiB
#include <bits/stdc++.h> using namespace std; using tup = tuple<int,int,int>; int n, q; int MAX_SUM = 0; constexpr int inf = 1e9; vector<int> solve(vector<tup> &data, bool mex) { vector<vector<int>> dp(data.size() + 1, vector<int>(MAX_SUM + 1,mex ? 0 : inf)); dp[0][0] = 0; for (int i = 1; i <= data.size() ; ++i) { auto [c, f, v] = data[i - 1]; for (int j = 0; j <= MAX_SUM; ++j) { dp[i][j] = dp[i - 1][j]; if (mex) { if (j - c >= 0) dp[i][j] = max(dp[i - 1][j],dp[i - 1][j - c] + v); } else { if (j - c >= 0) dp[i][j] = min(dp[i - 1][j],dp[i - 1][j - c] + v); } } } return dp[data.size()]; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; vector<tup> arr(n); int s1 = 0, s2 = 0; for (int i = 0; i < n; ++i) { int c, f, v; cin >> c >> f >> v; arr[i] = {c,f,v}; s1 += c; } cin >> q; vector<tup> sell(q); for (int i = 0; i < q; ++i) { int c, f, v; cin >> c >> f >> v; sell[i] = {c,f,v}; s2 += c; } MAX_SUM = max(s2, s1); auto c = solve(arr,false), p = solve(sell,true); int ans = 0; for (int i = 0; i <= MAX_SUM; ++i) { ans = max(ans, p[i] - c[i]); } cout << ans << "\n"; return 0; }

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

clo.cpp: In function 'std::vector<int> solve(std::vector<std::tuple<int, int, int> >&, bool)':
clo.cpp:13:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::tuple<int, int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |     for (int i = 1; i <= data.size() ; ++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...
#Verdict Execution timeMemoryGrader output
Fetching results...