이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#include<fstream>
#define ll long long
#define vt vector
#define pb push_back
#define fi first
#define se second
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
typedef unsigned long long ull;
#define pii pair<int, int>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
const ll mod= 1e9 + 7;
const int mxk = 1e3, sq = 750, mxn = 105;
const ll inf = -1e18;
int n, m;
ll d[2][2002][51], p[2005];
struct th{
ll c, f, v;
bool operator <(const th &b){
if(f != b.f)return(f > b.f);
return(v < b.v);
}
};
vt<th>a, b;
signed main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n; ll core = 0;
forr(i, 0, n){
int c, f, v; cin >> c >> f >> v;
a.pb({c, f, -v}); core += c;
}
cin >> m;
forr(i, 0, m){
int c, f, v; cin >> c >> f >> v;
a.pb({-c, f, v});
}
sort(a.begin(), a.end());
vt<ll>pre; pre.resize(core + 1, inf);
pre[0] = 0;
for(auto [c, f, v]: a){
vt<ll>curr; curr.resize(core + 1);
for(int j = 0; j <= core; j++)curr[j] = pre[j];
for(int i = 0; i <= core; i++){
int lft = i - c;
if(lft >= 0 && lft <= core && pre[lft] != inf){
curr[i] = max(curr[i], pre[lft] + v);
}
}
for(int j = 0; j <= core; j++)pre[j] = curr[j];
}
cout << *max_element(pre.begin(), pre.end());
return(0);
}
컴파일 시 표준 에러 (stderr) 메시지
clo.cpp: In function 'int main()':
clo.cpp:46:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
46 | for(auto [c, f, v]: a){
| ^
# | 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... |