제출 #153944

#제출 시각아이디문제언어결과실행 시간메모리
153944karmaCloud Computing (CEOI18_clo)C++14
100 / 100
425 ms1528 KiB
#include<bits/stdc++.h> #define pb emplace_back #define ll long long using namespace std; const int N = int(2e3) + 7; const int M = N * 55; const ll oo = (ll)1e18; struct TComp{ int c, f, v; bool type; bool operator<(const TComp& o)const& { return f > o.f || (f == o.f && type < o.type); } }; vector<TComp> v; ll f[M], res = 0; int n, m; int main() { ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); if(fopen("test.inp", "r")) { freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } cin >> n; v.resize(n); for(int i = 0; i < n; ++i) { cin >> v[i].c >> v[i].f >> v[i].v; v[i].v *= -1, v[i].type = 0; } cin >> m; m += n; v.resize(m); for(int i = n; i < m; ++i) { cin >> v[i].c >> v[i].f >> v[i].v; v[i].c *= -1, v[i].type = 1; } fill(f, f + M, -oo); f[0] = 0; sort(v.begin(), v.end()); for(TComp& comp: v) { if(comp.c > 0) { for(int i = int(1e5); i >= comp.c; --i) f[i] = max(f[i - comp.c] + comp.v, f[i]); } else { for(int i = 0, lim = int(1e5) + comp.c; i <= lim; ++i) f[i] = max(f[i - comp.c] + comp.v, f[i]); } } for(int i = 0; i < M; ++i) res = max(res, f[i]); cout << res; }

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

clo.cpp: In function 'int main()':
clo.cpp:26:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen("test.inp", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:27:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen("test.out", "w", stdout);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...