제출 #205698

#제출 시각아이디문제언어결과실행 시간메모리
205698dolphingarlicCloud Computing (CEOI18_clo)C++14
0 / 100
15 ms1916 KiB
#include <bits/stdc++.h> #define FOR(i, x, y) for (int i = x; i < y; i++) typedef long long ll; using namespace std; struct Object { int c; ll f, v; bool operator<(Object B) { return f > B.f; } } objects[4001]; ostream& operator<<(ostream& cout, Object X) { return cout << X.c << ' ' << X.f << ' ' << X.v; } ll dp[2][100001]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n, m; cin >> n; FOR(i, 0, n) { cin >> objects[i].c >> objects[i].f >> objects[i].v; objects[i].v *= -1; } cin >> m; FOR(i, n, n + m) { cin >> objects[i].c >> objects[i].f >> objects[i].v; objects[i].c *= -1; } sort(objects, objects + n + m); FOR(i, 0, 2) FOR(j, 0, 100001) dp[i][j] = LLONG_MIN / 2; dp[1][0] = 0; int mx = 0; FOR(i, 0, n + m) { FOR(j, 0, mx + 1 + objects[i].c) { if (j >= objects[i].c) dp[i & 1][j] = max(dp[1 - i & 1][j], dp[1 - i & 1][j - objects[i].c] + objects[i].v); else dp[i & 1][j] = dp[1 - i & 1][j]; } mx += max(0, objects[i].c); FOR(j, 0, mx + 1) dp[1 - i & 1][j] = LLONG_MIN / 2; } cout << *max_element(dp[1 - (n + m) & 1], dp[1 - (n + m) & 1] + mx + 1); return 0; }

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

clo.cpp: In function 'int main()':
clo.cpp:38:41: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
                 dp[i & 1][j] = max(dp[1 - i & 1][j], dp[1 - i & 1][j - objects[i].c] + objects[i].v);
                                       ~~^~~
clo.cpp:38:59: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
                 dp[i & 1][j] = max(dp[1 - i & 1][j], dp[1 - i & 1][j - objects[i].c] + objects[i].v);
                                                         ~~^~~
clo.cpp:39:38: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
             else dp[i & 1][j] = dp[1 - i & 1][j];
                                    ~~^~~
clo.cpp:42:32: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
         FOR(j, 0, mx + 1) dp[1 - i & 1][j] = LLONG_MIN / 2;
                              ~~^~~
clo.cpp:45:31: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
     cout << *max_element(dp[1 - (n + m) & 1], dp[1 - (n + m) & 1] + mx + 1);
                             ~~^~~~~~~~~
clo.cpp:45:52: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
     cout << *max_element(dp[1 - (n + m) & 1], dp[1 - (n + m) & 1] + mx + 1);
                                                  ~~^~~~~~~~~
#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...