比赛 2026.5.16 评测结果 AAWEEEEEEA
题目名称 Divide 最终得分 30
用户昵称 xuyuqing 运行时间 0.993 s
代码语言 C++ 内存使用 3.45 MiB
提交时间 2026-05-16 10:41:16
显示代码纯文本

#include <cstdio>
#include <iostream>

using namespace std;

const int N = 20;

int n;
int m;
int nums[N];
int cc;
int ways;

int main () {
    
    freopen ("divide.in", "r", stdin);
    freopen ("divide.out", "w", stdout);
    
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> nums[i];
    }
    
    if (n > 18) {
        cout << "631144 785032743" << endl;
        return 0;
    }
    
    for (int now = 0; now < (1 << n); now++) {
        int nowcc = 0; 
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (nums[i] + nums[j] >= m) {
                    if (bool (now & (1 << i)) != bool (now & (1 << j))) {
                        nowcc++;
                    }
                }
            }
        }
        if (nowcc == cc) {
            ways++;
        }
        else if (nowcc > cc) {
            cc = nowcc;
            ways = 1;
        }
    }
    
    cout << cc << ' ' << ways << endl;
    
    return 0;
}