제출 #163785

#제출 시각아이디문제언어결과실행 시간메모리
163785Alexa2001Cloud Computing (CEOI18_clo)C++17
100 / 100
441 ms2168 KiB
#include <bits/stdc++.h> using namespace std; const int Nmax = 2004; typedef long long ll; const ll inf = 1e18; struct ev { int c, v, f, tip; } a[2 * Nmax]; int n, m; void solve() { vector<ll> dp(50 * (n - m) + 1), old(50 * (n - m) + 1, -inf); int i, j; old[0] = 0; for(i=1; i<=n; ++i) { if(a[i].tip == 0) { for(j=0; j<a[i].c; ++j) dp[j] = old[j]; for(j=a[i].c; j<dp.size(); ++j) dp[j] = max(old[j], old[j-a[i].c] - a[i].v); } else { for(j=0; j + a[i].c < dp.size(); ++j) dp[j] = max(old[j], old[j+a[i].c] + a[i].v); for(; j < dp.size(); ++j) dp[j] = old[j]; } swap(dp, old); } cout << ( *max_element(old.begin(), old.end()) ) << '\n'; } int main() { // freopen("input", "r", stdin); cin.tie(0); cin.sync_with_stdio(false); int i, C, F, V; cin >> n; for(i=1; i<=n; ++i) { cin >> C >> F >> V; a[i] = {C, V, F, 0}; } cin >> m; for(i=1; i<=m; ++i) { cin >> C >> F >> V; a[i+n] = {C, V, F, 1}; } n += m; sort(a+1, a+n+1, [] (ev x, ev y) { if(x.f != y.f) return x.f > y.f; return x.tip < y.tip; } ); solve(); return 0; }

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

clo.cpp: In function 'void solve()':
clo.cpp:29:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(j=a[i].c; j<dp.size(); ++j)
                           ~^~~~~~~~~~
clo.cpp:34:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(j=0; j + a[i].c < dp.size(); ++j)
                      ~~~~~~~~~~~^~~~~~~~~~~
clo.cpp:37:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(; j < dp.size(); ++j)
                   ~~^~~~~~~~~~~
#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...