Advertisement
apl-mhd

prev update wedding

Aug 13th, 2017
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.66 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <vector>
  5.  
  6.  
  7. using namespace std;
  8. /*
  9.     8 6 4
  10. 2 5 10
  11. 4 1 3 3 7
  12. 4 50 14 23 8
  13.     */
  14.  
  15. int main(int argc, char **argv)
  16. {
  17.  
  18.  
  19.  
  20.     int testCase;
  21.     cin>>testCase;
  22.     cout<<testCase;
  23.     while(testCase--){
  24.  
  25.     int totalAmount, cloths;
  26.    
  27.     vector<int>garment[cloths];
  28.     cin>>totalAmount>>cloths;
  29.    
  30.     for(int m=0; m<cloths; m++){
  31.         int tklen;
  32.         cin>>tklen;
  33.        
  34.         for(int n=0; n<tklen; n++){
  35.            
  36.             int tk;
  37.             cin>>tk;
  38.             garment[m].push_back(tk);
  39.    
  40.    
  41. }
  42. cout<<"end tk len";
  43.  
  44. }
  45.    
  46.     for(int i=0; i<cloths-1; i++){
  47.        
  48.         int secondSize = garment[i+1].size();
  49.        
  50.         for(int j=0; j<garment[i].size(); j++){
  51.                 int x = garment[i][j];
  52.            
  53.             for(int k=0; k<secondSize; k++){
  54.                
  55.                 int y = garment[i+1][k];
  56.                
  57.                 if (x+y < totalAmount & (i!=cloths-2))
  58.                     garment[i+1].push_back(x+y);
  59.                 else if(x+y<= totalAmount)
  60.                     garment[i+1].push_back(x+y);
  61.                
  62.                 }
  63.            
  64.                
  65.             }
  66.            
  67.             garment[i+1].erase(garment[i+1].begin(),garment[i+1].begin()+secondSize);
  68.        
  69.         }
  70.        
  71.        
  72.  
  73. for(int i=0; i<cloths; i++){
  74.        
  75.         //sort(garment[3].begin(), garment[3].end());
  76.        
  77.         for (int j=0; j<garment[i].size(); j++){
  78.            
  79.             cout<<garment[i][j]<<" ";
  80.             }
  81.            
  82.         cout<<endl<<"\n";
  83.        
  84.         }  
  85.        
  86.         cout<<"after short\n";
  87.  
  88.     sort(garment[cloths-1].begin(), garment[cloths-1].end(), greater<int>());
  89.    
  90.     for (int j=0; j<garment[cloths-1].size(); j++){
  91.            
  92.             cout<<garment[cloths-1][j]<<" ";
  93.             }
  94.            
  95.         cout<<endl<<"\n";
  96.        
  97.        
  98.  
  99.        
  100.    
  101. }
  102.     return 0;
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement