제출 #318943

#제출 시각아이디문제언어결과실행 시간메모리
318943DymoCloud Computing (CEOI18_clo)C++14
100 / 100
544 ms2276 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back #define eb emplace_back #define ll long long #define pll pair<ll,ll> #define ff first #define ss second #define endl "\n" const ll maxn=1e5+54; const ll mod =1e9+7 ; const ll base=1e18; ll dp[3][maxn]; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); if (fopen("t.txt", "r")) { freopen("test.txt", "r", stdin); // freopen("team.out", "w", stdout); } ll n, m; cin>> n ; vector<pair<ll,pll>> vt; for (int i=1;i<=n;i++) { ll c,f, v; cin>> c>> f>> v; v=-v; vt.pb(make_pair(f,make_pair(c,v))); } cin>>m; for (int i=1;i<=m;i++) { ll c, f, v; cin>> c>> f>> v; c=-c; vt.pb(make_pair(f,make_pair(c,v))); } for (int i=0;i<maxn;i++) { dp[0][i]=dp[1][i]=-1e15; } dp[0][0]=0; sort(vt.rbegin(),vt.rend()); ll cnt=0; for (auto p:vt) { cnt++; ll now=cnt%2; ll pre=1-now; ll cst=p.ss.ss; ll num=p.ss.ff; for (int i=0;i<maxn;i++) { dp[now][i]=dp[pre][i]; if (i-num<maxn&&i-num>=0) { dp[now][i]=max(dp[now][i],dp[pre][i-num]+cst); } } } ll ans=0; for (int i=0;i<maxn;i++) { ans=max(ans,dp[cnt%2][i]); } cout <<ans; }

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

clo.cpp: In function 'int main()':
clo.cpp:24:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   24 |         freopen("test.txt", "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...