제출 #998751

#제출 시각아이디문제언어결과실행 시간메모리
998751vjudge1Cloud Computing (CEOI18_clo)C++17
100 / 100
955 ms2188 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; ll n, q; ll maxn = 0; const ll inf = 1e18; vector<ll> solve(vector<tuple<ll,ll,ll>> &data, bool mex) { vector<ll> dp(vector<ll>(maxn + 1,mex ? -inf : inf)); dp[0] = 0; for (ll i = 1; i <= data.size() ; ++i) { vector<ll> ndp = dp; auto [f,c, v] = data[i - 1]; for (ll j = 0; j <= maxn; ++j) { if (mex) { if (j - c >= 0 && j - c <= maxn) ndp[j] = max(dp[j],dp[j - c] + v); } else { if (j - c >= 0 && j - c <= maxn) ndp[j] = min(dp[j],dp[j - c] + v); } } dp = ndp; } return dp; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cin >> n; vector<tuple<ll,ll,ll>> arr; ll s1 = 0, s2 = 0; for (ll i = 0; i < n; ++i) { ll c, f, v; cin >> c >> f >> v; arr.emplace_back(f,c,-v); s1 += c; } cin >> q; for (ll i = 0; i < q; ++i) { ll c, f, v; cin >> c >> f >> v; arr.emplace_back(f,-c,v); s2 += c; } maxn = max(s2, s1); sort(arr.begin(), arr.end()); reverse(arr.begin(), arr.end()); auto c = solve(arr, true); ll ans = 0; for (int i = 0; i <= maxn; ++i) { ans = max(c[i],ans); } cout << ans << "\n"; return 0; }

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

clo.cpp: In function 'std::vector<long long int> solve(std::vector<std::tuple<long long int, long long int, long long int> >&, bool)':
clo.cpp:11:22: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::tuple<long long int, long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for (ll 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...