제출 #1167191

#제출 시각아이디문제언어결과실행 시간메모리
1167191SmuggingSpunCloud Computing (CEOI18_clo)C++20
18 / 100
218 ms2052 KiB
#include<bits/stdc++.h> #define taskname "A" using namespace std; typedef long long ll; template<class T>void minimize(T& a, T b){ if(a > b){ a = b; } } template<class T>void maximize(T& a, T b){ if(a < b){ a = b; } } const int lim = 2e3 + 5; const ll INF = 1e18; struct Data{ int c, f, v; bool operator <(const Data& other){ return this->f < other.f; } }; int n, m; Data a[lim], b[lim]; namespace sub4{ const int LIM = 1e5 + 5; ll dp_a[LIM], dp_b[LIM]; void solve(){ memset(dp_a, 0x0f, sizeof(dp_a)); memset(dp_b, -0x0f, sizeof(dp_b)); ll ans = dp_a[0] = dp_b[0] = 0; for(int i = 1; i <= n; i++){ for(int j = LIM - 1; j >= a[i].c; j--){ minimize(dp_a[j], dp_a[j - a[i].c] + a[i].v); } } for(int i = LIM - 2; i > -1; i--){ minimize(dp_a[i], dp_a[i + 1]); } for(int i = 1; i <= m; i++){ for(int j = LIM - 1; j >= b[i].c; j--){ maximize(dp_b[j], dp_b[j - b[i].c] + b[i].v); } } for(int i = 0; i < LIM; i++){ maximize(ans, dp_b[i] - dp_a[i]); } cout << ans; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if(fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); } cin >> n; for(int i = 1; i <= n; i++){ cin >> a[i].c >> a[i].f >> a[i].v; } cin >> m; for(int i = 1; i <= m; i++){ cin >> b[i].c >> b[i].f >> b[i].v; } sort(a + 1, a + n + 1); sort(b + 1, b + m + 1); if(a[n].f == 1 && b[m].f == 1){ sub4::solve(); } }

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

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