제출 #775856

#제출 시각아이디문제언어결과실행 시간메모리
775856DzadzoCloud Computing (CEOI18_clo)C++17
0 / 100
95 ms262144 KiB
#include <bits/stdc++.h> #define ll long long #define int ll #define pb push_back #define S second #define F first #define pii pair<int,int> #define vi vector <int> #define vvi vector <vector<int>> #define INF LLONG_MAX #define MOD 1000000009 #define MAXN 4000 using namespace std; int c[MAXN+1],f[MAXN+1],v[MAXN+1]; bool comp(int a,int b){ if (f[a]>f[b])return true; if (f[a]<f[b])return false; return v[a]<v[b]; } main() { ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL); // freopen("problemname.in", "r", stdin); // freopen("problemname.out", "w", stdout); int n; cin>>n; for (int i=1;i<=n;i++){ int q1,q2,q3; cin>>q1>>q2>>q3; c[i]=q1; f[i]=q2; v[i]=-q3; } int m; cin>>m; for (int i=n+1;i<=n+m;i++){ int q1,q2,q3; cin>>q1>>q2>>q3; c[i]=-q1; f[i]=q2; v[i]=q3; } int ind[MAXN+1]; for (int i=1;i<=n+m;i++)ind[i]=i; sort(ind+1,ind+n+m+1,comp); vvi dp(MAXN+1,vi (MAXN*50+1,-INF)); dp[0][0]=0; for (int i=1;i<=n+m;i++){ for (int k=0;k<=MAXN*50;k++){ dp[i][k]=max(dp[i][k],dp[i-1][k]); if (k-c[ind[i]]>=0 && k-c[ind[i]]<=MAXN*50){ if (dp[i-1][k-c[ind[i]]]!=-INF){ dp[i][k]=max(dp[i][k],dp[i-1][k-c[ind[i]]]+v[ind[i]]); } } } } // for (int i=1;i<=n+m;i++)cout<<c[ind[i]]<<" "<<f[ind[i]]<<" "<<v[ind[i]]<<"\n"; int ans=0; for (int i=0;i<=MAXN*50;i++)ans=max(ans,dp[n+m][i]); /* for (int i=1;i<=n+m;i++){ cout<<"---"<<i<<"---\n"; for (int k=0;k<=MAXN*50;k++){ if (dp[i][k]!=-INF) cout<<k<<" "<<dp[i][k]<<"\n"; } cout<<"\n"; } */ cout<<ans; }

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

clo.cpp:20:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   20 | main() {
      | ^~~~
#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...