제출 #716816

#제출 시각아이디문제언어결과실행 시간메모리
716816BaytoroCloud Computing (CEOI18_clo)C++17
100 / 100
626 ms2124 KiB
#include <bits/stdc++.h> using namespace std; #define ios ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); #define pb push_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() #define fr first #define sc second #define endl '\n' #define ll long long #define int long long void fopn(string name){ freopen((name+".in").c_str(),"r",stdin); freopen((name+".out").c_str(),"w",stdout); } const ll INF=1e18,mod=1e9+9,N=2e5+5; struct node{ int c,f,p; } a[4005]; bool cmp(node a, node b){ if(a.f==b.f) return a.p<b.p; return a.f>b.f; } void solve(){ int n;cin>>n; int sum=0; for(int i=0;i<n;i++) {cin>>a[i].c>>a[i].f>>a[i].p;a[i].p=-a[i].p,sum+=a[i].c;} int m;cin>>m; for(int i=n;i<n+m;i++) {cin>>a[i].c>>a[i].f>>a[i].p;a[i].c=-a[i].c;} sort(a,a+n+m,cmp); vector<int> pref(sum+1,-INF),prev(sum+1,-INF); pref[0]=prev[0]=0; for(int i=0;i<n+m;i++){ for(int j=0;j<=sum;j++){ int x=j-a[i].c; if(0<=x && x<=sum && pref[x]!=-INF){ prev[j]=max(prev[j],pref[x]+a[i].p); } } pref=prev; } int ans=-INF; for(auto it: pref) ans=max(ans,it); cout<<ans; } main(){ //fopn("team"); //ios; int T=1; //cin>>T; for(int i=1;i<=T;i++){ //cout<<"Case #"<<i<<": "; solve(); } }

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

clo.cpp:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   46 | main(){
      | ^~~~
clo.cpp: In function 'void fopn(std::string)':
clo.cpp:13:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
clo.cpp:14:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  freopen((name+".out").c_str(),"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...