TOJ 1609 Moo University - Team Tryouts

题目链接:http://acm.tzc.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1609

真是好题啊。。。关于题解可以参考这三个地址:

POJ 2008 Moo University - Team Tryouts 牛题


poj 2008 Moo University - Team Tryouts 解题报告2


March 2004 Green problems with analysis

#include 
   
   
    
    
#include 
    
    
     
     
#include 
     
     
      
      
#include 
      
      
       
       
#include 
       
       
         #include 
         #include 
         
           #include 
          
            #include 
           
             #include 
            
              #include 
             
               #include 
              
                #include 
               
                 #include 
                
                  #include 
                 
                   #include 
                  
                    #define mp make_pair #define X first #define Y second #define MEMSET(a, b) memset(a, b, sizeof(a)) using namespace std; typedef unsigned int ui; typedef long long ll; typedef unsigned long long ull; typedef pair 
                   
                     pii; typedef vector 
                    
                      vi; typedef vi::iterator vi_it; typedef map 
                     
                       mii; typedef priority_queue 
                      
                        pqi; typedef priority_queue 
                       
                         , greater 
                        
                          > rpqi; typedef priority_queue 
                         
                           pqp; typedef priority_queue 
                          
                            , greater 
                           
                             > rpqp; const int MAX_N = 1000 + 2; typedef struct cow { int w; int h; int k; } *pcow; cow cw[MAX_N]; pcow sort_w[MAX_N]; pcow sort_k[MAX_N]; bool cmp_w(const pcow &c1, const pcow &c2) { return c1->w < c2->w; } bool cmp_k(const pcow &c1, const pcow &c2) { return c1->k < c2->k; } struct rcmp { bool operator () (const pcow &c1, const pcow &c2) { return c1->w > c2->w; } }; int main(int argc, char *argv[]) { // freopen("D:\\in.txt", "r", stdin); int n, a, b, c, i, j; cin >> n >> a >> b >> c; for (i = 0; i < n; ++i) { cin >> cw[i].h >> cw[i].w; cw[i].k = a * cw[i].h + b * cw[i].w; sort_w[i] = cw + i; sort_k[i] = cw + i; } sort(sort_w, sort_w + n, cmp_w); sort(sort_k, sort_k + n, cmp_k); sort_w[n] = new cow(); sort_w[n]->w = 0; priority_queue 
                            
                              , rcmp> q; int ans = 0; for (i = 0; i < n; ++i) { int pos = 0, cnt = 0; while (!q.empty()) { q.pop(); } for (j = 0; j < n && sort_w[j]->w <= cw[i].w; ++j) { if (sort_w[j]->w == sort_w[j + 1]->w) { continue; } int lmt = a * cw[i].h + b * sort_w[j]->w + c; while (pos < n && sort_k[pos]->k <= lmt) { if (sort_k[pos]->h >= cw[i].h && sort_k[pos]->w >= sort_w[j]->w) { q.push(sort_k[pos]); ++cnt; } ++pos; } if (cnt > ans) { ans = cnt; } while (!q.empty() && q.top()->w == sort_w[j]->w) { q.pop(); --cnt; } } } cout << ans << endl; return 0; } 
                             
                            
                           
                          
                         
                        
                       
                      
                     
                    
                   
                  
                 
                
               
              
             
            
           
          
       
      
      
     
     
    
    
   
   

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值