QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#558620 | #8932. Bingo | Yarema# | WA | 0ms | 3544kb | C++20 | 1.3kb | 2024-09-11 17:11:18 | 2024-09-11 17:11:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (a) - 1; i >= (b); i--)
#define SZ(a) int(a.size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
#define F first
#define S second
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef double db;
const int INF = 1e9;
const int N = 74;
int n;
PII lr[N];
int w[N];
bool ok = false;
int ans = -INF;
bool hasBit(LL mask, int i)
{
return (mask >> i) & 1;
}
void rec(int sz, LL used, int cost)
{
if (__builtin_popcount(used) == n)
{
ok = true;
ans = max(ans, cost);
return;
}
if (sz < n)
rec(sz + 1, used, cost);
int cnt = 0;
FOR(i, 0, n)
{
if (!hasBit(used, i) && lr[i].F <= sz && sz <= lr[i].S && cnt < sz)
{
used |= 1LL << i;
cnt++;
}
}
if (cnt == sz)
rec(sz, used, cost + w[sz]);
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
FOR (i, 0, n)
cin >> lr[i].F >> lr[i].S;
FOR (i, 1, n)
cin >> w[i];
sort(lr, lr + n, [](const PII& p1, const PII& p2)
{
return p1.S < p2.S;
});
rec(1, 0, 0);
if (!ok)
cout << "impossible\n";
else
cout << ans << "\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3544kb
input:
6 7 3 12 3 9 10 249 51 1369 37 2 1
output:
impossible
result:
wrong answer 1st lines differ - expected: '9', found: 'impossible'