답안 #883426

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
883426 2023-12-05T09:15:08 Z ComGa999ms San (COCI17_san) C++17
48 / 120
182 ms 444 KB
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
#define int long long
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define repd(i, r, l) for (int i = r; i >= l; --i)
#define _unique(x) (x).resize(unique((x).begin(), (x).end()) - (x).begin());
#define sz(v) (int)(v).size()
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mp make_pair
#define eps double(1e-9)
#define vii vector<int>
#define pii pair<int,int>
#define p2i pair<int,pii>
#define endl '\n'

using namespace std;

const int N = 1e6 + 5;
const int MN = 2e3 + 5;
const int mod = 1e9 + 7;
const int inf = 1e18 + 7;
const bool Emily = false;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l, int r) {
    return l+rng()%(r-l+1);
}

bool minimize(int &a, int b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

bool maximize(int &a, int b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

int n, k;
pair <int, int> a[N];

void solve(void) {
    cin >> n >> k;
    rep(i, 0, n - 1) cin >> a[i].fi >> a[i].se;

    int res = 0;
    rep(mask, 0, (1 << n) - 1) {
        vector <pii> candidates;

        #define bit(x, i) (1LL & (x >> i))
        rep(i, 0, n - 1) if (bit(mask, i)) {
            candidates.push_back(a[i]);
        }

        bool ok = true;
        rep(i, 1, sz(candidates) - 1) {
            if (candidates[i - 1] > candidates[i]) {
                ok = false;
                break;
            }
        }

        int temp = 0;
        rep(i, 0, sz(candidates) - 1) temp += candidates[i].se;
        if (temp < k) ok = false;

        res += ok;
    }
    cout << res << endl;
}

signed main()
{
    #define task "GDREAM"
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen(task".inp", "r", stdin);
    //freopen(task".out", "w", stdout);

    if (Emily) {
        int t; cin >> t;
        while (t-- ) solve();
    } else solve();

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 3 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 182 ms 348 KB Output is correct
2 Correct 170 ms 444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -