제출 #1093295

#제출 시각아이디문제언어결과실행 시간메모리
1093295InvMODCloud Computing (CEOI18_clo)C++14
0 / 100
1 ms600 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; template<typename T> bool ckmx(T& a, const T b){if(a < b) return a = b, true; return false;} template<typename T> bool ckmn(T& a, const T b){if(a > b) return a = b, true; return false;} const int N = 2e3+5; int n, m, f[N]; int F[N], c[N], C[N]; ll v[N], V[N]; namespace Sub4{ bool ckSub() { int cnt_num = 0; for(int i = 1; i <= max(n,m); i++){ cnt_num += (f[i] == 1); cnt_num += (F[i] == 1); } return cnt_num == n+m; } const ll INF = 1e18; vector<ll> f, g; void solve() { int sumRoom = 0; for(int i = 1; i <= n; i++){ sumRoom += c[i]; } f.assign(sumRoom+1, INF); sumRoom = 0; for(int i = 1; i <= m; i++){ sumRoom += C[i]; } g.assign(sumRoom+1, -INF); f[0] = g[0] = 0; for(int i = 1; i <= n; i++){ for(int j = (int)f.size()-1; j >= c[i]; j--){ ckmn(f[j], f[j - c[i]] + v[i]); } } for(int i = 1; i <= m; i++){ for(int j = (int)g.size()-1; j >= C[i]; j--){ ckmx(g[j], g[j - C[i]] + V[i]); } } //for(int j = (int)f.size()-2; j >= 0; j--) f[j] = min(f[j], f[j+1]); ll answer = 0; for(int i = 1; i <= min((int)f.size(), (int)g.size())-1; i++){ answer = max(answer, g[i] - f[i]); } cout << answer <<"\n"; } } void process() { cin >> n; for(int i = 1; i <= n; i++){ cin >> c[i] >> f[i] >> v[i]; } cin >> m; for(int i = 1; i <= m; i++){ cin >> C[i] >> F[i] >> V[i]; } if(Sub4::ckSub()){ Sub4::solve(); } } int32_t main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define name "InvMOD" if(fopen(name".INP", "r")){ freopen(name".INP", "r", stdin); freopen(name".OUT", "w", stdout); } process(); return 0; }

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

clo.cpp: In function 'int32_t main()':
clo.cpp:89:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   89 |         freopen(name".INP", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:90:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   90 |         freopen(name".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...