1 solutions

  • 0
    @ 2022-8-28 19:05:31

    这题是个完全背包,题目多

    #include <bits/stdc++.h>
    using namespace std;
    #define ll long long
    const ll N = 1e8+10;
    const ll M = 1e6+10;
    
    int f[N];
    
    int main(){
    	int n,m,V,g=0,fa=0;
    	cin>>n>>m>>V;
    	for(int i=0;i<n;i++){
    		int v,w,s;
    		cin>>v>>w>>s;
    		if(s==-1){
    			for(int j=v;j<=V;j++){
    				f[j]=max(f[j],f[j-v]+w);
    			}
    		}
    		else if(s==0&&v==0){
    			if(w>g) g=w;
    		}
    		else if(v==0&&s==1){
    			if(w>fa) fa=w;
    		}
    	}
    	if(f[V]+g>=m+fa) cout<<f[V]+g<<" "<<m+fa<<endl<<"泪目"<<endl;
    	else cout<<f[V]+g<<" "<<m+fa<<endl<<"优雅"<<endl;
    
    
    	return 0;
    }
    
    • 1

    Information

    ID
    6549
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    9
    Tags
    # Submissions
    14
    Accepted
    4
    Uploaded By