zoukankan      html  css  js  c++  java
  • POJ 2782

     1 #include <iostream>
     2 #include <algorithm>
     3 #define MAXN 100005
     4 using namespace std;
     5 
     6 int _m[MAXN];
     7 bool op(int a,int b);
     8 int main()
     9 {
    10     //freopen("acm.acm","r",stdin);
    11     int n;
    12     int l;
    13     int i;
    14     int j;
    15     int ans = 0;
    16     //cin>>n;
    17     //cin>>l;
    18     scanf("%d",&n);
    19     scanf("%d",&l);
    20     for(i = 0; i < n; ++ i)
    21     {
    22        // cin>>_m[i];
    23        scanf("%d",&_m[i]);
    24     }
    25     sort(_m,_m+n,op);
    26 
    27     j = n-1;
    28     for(i = 0; i < j;)
    29     {
    30         if(_m[i]+_m[j] <= l)
    31         {
    32             ++ ans;
    33             ++ i;
    34             -- j;
    35         }
    36         else
    37         {
    38             ++ i;
    39             ++ ans;
    40         }
    41     }
    42     if(i == j)
    43     {
    44         ++ ans;
    45     }
    46     cout<<ans<<endl;
    47     return 0;
    48 }
    49 
    50 bool op(int a,int b)
    51 {
    52     return a > b;
    53 }
  • 相关阅读:
    Win10安装组策略功能
    IIS 站点批量迁移
    MongoDB 异常记录
    微信Web开发者工具
    NHibernate 异常
    Git 常用命令
    IIS 反向代理
    CSS应用
    Oracle
    Android之ActionBar学习
  • 原文地址:https://www.cnblogs.com/gavinsp/p/4568679.html
Copyright © 2011-2022 走看看