AtCoder Grand Contest 029-B-Powers of two

 

 

题目链接

 

给你n个数,求最多的两个数相加为2的幂(用过的不能再用)的个数

 

 

真没想到居然就是sort一下,然后尺取、我都想到 二分图匹配匈牙利、网络流 去了

 

#include
typedef long long ll;
using namespace std;
const int maxn = 2e5+7;
int read(){
    int c = getchar(),Nig = 1,x = 0;
    while(!isdigit(c))
        c = getchar();
    if(c == '-')
        Nig = -1,c = getchar();
    while(isdigit(c))
        x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
    return Nig*x;
}
#define read read()
int a[maxn],n,ans;
int main(){
    n = read;
    for(int i=0;i>=1){
        int l = 0,r = n-1;
        while(lk)
                r--;
            else{
                ans++;
                a[l] = a[r] = -1;
            }
        }
    }
    printf("%d\n",ans);
	return 0;
}

 

你可能感兴趣的:(思维(抖啊,抖啊,抖个机灵儿))