結果

問題 No.1538 引きこもりさんは引き算が得意。
コンテスト
ユーザー AngrySadEight
提出日時 2026-02-15 01:12:16
言語 C++17
(gcc 15.2.0 + boost 1.89.0)
結果
WA  
実行時間 -
コード長 4,502 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,899 ms
コンパイル使用メモリ 220,588 KB
実行使用メモリ 7,976 KB
最終ジャッジ日時 2026-02-15 01:12:24
合計ジャッジ時間 7,010 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 34 WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <algorithm>
#include <atcoder/all>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using namespace atcoder;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define repk(i, k, n) for (int i = k; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define mod1 1000000007
#define mod2 998244353
#define mod3 100000007
#define vi vector<int>
#define vs vector<string>
#define vc vector<char>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vector<int>>
#define vvc vector<vector<char>>
#define vvl vector<vector<ll>>
#define vvb vector<vector<bool>>
#define vvvi vector<vector<vector<int>>>
#define vvvl vector<vector<vector<ll>>>
#define pii pair<int, int>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define vpii vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define vvpii vector<vector<pair<int, int>>>
#define vvpll vector<vector<pair<ll, ll>>>

template <typename T>
void debug(T e) {
    cerr << e << endl;
}

template <typename T>
void debug(vector<T> &v) {
    rep(i, v.size()) { cerr << v[i] << " "; }
    cerr << endl;
}

template <typename T>
void debug(vector<vector<T>> &v) {
    rep(i, v.size()) {
        rep(j, v[i].size()) { cerr << v[i][j] << " "; }
        cerr << endl;
    }
}

template <typename T>
void debug(vector<pair<T, T>> &v) {
    rep(i, v.size()) { cerr << v[i].first << " " << v[i].second << endl; }
}

template <typename T>
void debug(set<T> &st) {
    for (auto itr = st.begin(); itr != st.end(); itr++) {
        cerr << *itr << " ";
    }
    cerr << endl;
}

template <typename T>
void debug(multiset<T> &ms) {
    for (auto itr = ms.begin(); itr != ms.end(); itr++) {
        cerr << *itr << " ";
    }
    cerr << endl;
}

template <typename T>
void debug(map<T, T> &mp) {
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        cerr << itr->first << " " << itr->second << endl;
    }
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << H << " ";
    debug_out(T...);
}

using mint = modint998244353;

void debug_mint1(vector<mint> &vec) {
    for (int i = 0; i < vec.size(); i++) {
        cerr << vec[i].val() << " ";
    }
    cerr << endl;
}

void debug_mint2(vector<vector<mint>> &vec) {
    for (int i = 0; i < vec.size(); i++) {
        for (int j = 0; j < vec[i].size(); j++) {
            cerr << vec[i][j].val() << " ";
        }
        cerr << endl;
    }
}

ll partite(vector<pll> &ans, ll H, ll W, multiset<pair<pll, ll>> &st_x, multiset<pair<pll, ll>> &st_y){
    ll now_x = 0;
    ll now_y = 0;
    while (st_x.size()){
        auto itx = st_x.end();
        itx--;
        auto ity = st_y.end();
        ity--;
        ll max_x = (*itx).first.first;
        ll then_y = (*itx).first.second;
        ll then_idx = (*itx).second;
        ll max_y = (*ity).first.first;
        ll then_x = (*ity).first.second;
        ll then_idy = (*ity).second;
        if (max_x == H - now_x){
            ans[then_idx] = make_pair(now_x + 1, now_y + 1);
            now_y += then_y;
            st_x.erase(st_x.find(make_pair(make_pair(max_x, then_y), then_idx)));
            st_y.erase(st_y.find(make_pair(make_pair(then_y, max_x), then_idx)));
        }
        else if (max_y == W - now_y){
            ans[then_idy] = make_pair(now_x + 1, now_y + 1);
            now_x += then_x;
            st_x.erase(st_x.find(make_pair(make_pair(then_x, max_y), then_idy)));
            st_y.erase(st_y.find(make_pair(make_pair(max_y, then_x), then_idy)));
        }
        else{
            return -1;
        }
    }
    return 0;
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N){
        cin >> A[i];
    }
    for (ll i = 0; i < (1 << N); i++){
        ll popcnt = 0;
        ll sums = 0;
        rep(j, N){
            if ((i >> j) & 1){
                popcnt++;
                sums += A[j];
            }
        }
        if (popcnt >= 1 && popcnt <= N - 1 && sums == K){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

0