이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <iostream>
#define ll long long
#define pb push_back
#define F first
#define S second
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
ll n;
cin >> n;
vector<pair<pair<ll,ll>, pair<ll,ll> > > action;
for(ll i = 0; i < n; i++){
ll c, f, v;
cin >> c >> f >> v;
action.pb({{f, 1}, {v, c}});
}
ll m;
cin >> m;
for(ll i = 0; i < m; i++){
ll c, f, v;
cin >> c >> f >> v;
action.pb({{f, 0}, {v, c}});
}
sort(action.begin(), action.end());
vector<ll> ans(50 * n + 1, -1e9); ans[0] = 0;
while(!action.empty()){
ll curC = action[action.size() - 1].S.S;
ll curV = action[action.size() - 1].S.F;
ll curT = action[action.size() - 1].F.S;
if(curT == 1){
for(ll i = 50 * n - curC; i >= 0; i--){
if(ans[i + curC] < ans[i] - curV){
ans[i + curC] = ans[i] - curV;
}
}
}
else{
for(ll i = curC; i <= 50 * n; i++){
if(ans[i - curC] < ans[i] + curV){
ans[i - curC] = ans[i] + curV;
}
}
}
action.pop_back();
}
ll ansG = 0;
for(int i = 0; i < ans.size(); i++){
ansG = max(ansG, ans[i]);
//cout << ans[i] << endl;
}
cout << ansG << endl;
}
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp: In function 'int main()':
clo.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
63 | for(int i = 0; i < ans.size(); i++){
| ~~^~~~~~~~~~~~
# | 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... |