QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#619596 | #8936. Team Arrangement | ucup-team4074# | Compile Error | / | / | Python3 | 2.0kb | 2024-10-07 14:44:57 | 2024-10-07 14:44:58 |
Judging History
This is the latest submission verdict.
- [2024-10-07 14:44:58]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-10-07 14:44:57]
- Submitted
answer
#include <bits/stdc++.h>
//#define int long long
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define pb push_back
using namespace std;
const int N = 65;
void solve();
signed main() {
// fast
int t = 1;
// cin >> t;
while (t--) solve();
}
const int INF = 1e9;
int ans(-INF);
int n, w[N];
struct item {
int l, r;
} a[N];
bool cmp(item x, item y) {
return x.l <= y.l;
}
template<typename T>
class CMP {
public:
bool operator()(T x, T y) {
return a[x].r > a[y].r;
}
};
priority_queue<int, vector<int>, CMP<int>> q;
int now[N], cnt;
int now_val;
int check() {
// cout << 1 << '\n';
int flag(1), head(1);
while (!q.empty())q.pop();
for (int i = 1; i <= n; i++) {
while (a[head].l <= now[i] && head <= n)q.push(head), head++;
if ((!q.empty()) && a[q.top()].r < now[i]) {
flag = 0;
}
if (!q.empty())q.pop();
else flag = 0;
}
if (!q.empty() || head <= n)flag = 0;
return flag;
}
void dfs(int sum, int lim) {
if (sum == 0) {
if (ans < now_val) {
if (check()) {
ans = now_val;
}
}
return;
}
for (int i = lim; i <= sum; i++) {
now_val += w[i];
for (int j = 1; j <= i; j++) {
++cnt;
now[cnt] = i;
}
dfs(sum - i, i);
for (int j = 1; j <= i; j++)cnt--;
now_val -= w[i];
}
return;
}
void solve() {
cin >> n;
for (int i = 1; i <= n; i++)cin >> a[i].l >> a[i].r;
for (int i = 1; i <= n; i++)cin >> w[i];
stable_sort(a + 1, a + n + 1, cmp);
dfs(n, 1);
if (ans == -INF)cout << "impossible";
else cout << ans << '\n';
return;
}
/*
3
2 3
1 2
2 2
4 5 100
3
1 3
3 3
2 3
1 1 100
2
1 1
2 2
1 1
3
1 2
1 2
1 2
1 100000 1
5
1 5
1 5
1 5
1 5
1 5
-1 -1 -2 -1 -2
*/
Details
File "answer.code", line 2 //#define int long long ^^ SyntaxError: invalid syntax