이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
//In the name of God
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MXN = 4e3 + 10;
const ll MXM = 2e5 + 10;
ll n, m; bool Tp[MXN];
ll M[MXN], F[MXN], T[MXN], Ind[MXN], dp[MXM];
void ckmx(ll &x, ll y){ x = max(x, y); }
int main(){
ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
cin >> n, iota(Ind + 1, Ind + MXN, 1);
for(int i = 1; i <= n; i ++) cin >> T[i] >> F[i] >> M[i]; cin >> m;
for(int i = 1; i <= m; i ++) cin >> T[i + n] >> F[i + n] >> M[i + n], Tp[i + n] = 1;
sort(Ind + 1, Ind + n + m + 1, [&](const int &i, const int &j){ return F[i] < F[j]; });
for(int ii = 1; ii <= n + m; ii ++){ int i = Ind[ii];
if(Tp[i]) for(int j = MXM - 1; j >= T[i]; -- j) ckmx(dp[j], dp[j - T[i]] + M[i]);
else for(int j = 0; j < MXM - T[i]; j ++) ckmx(dp[j], dp[j + T[i]] - M[i]);
} cout << dp[0] << '\n';
return 0;
}
//N.N
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp: In function 'int main()':
clo.cpp:14:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
14 | for(int i = 1; i <= n; i ++) cin >> T[i] >> F[i] >> M[i]; cin >> m;
| ^~~
clo.cpp:14:60: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
14 | for(int i = 1; i <= n; i ++) cin >> T[i] >> F[i] >> M[i]; cin >> m;
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |