QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#619788 | #8936. Team Arrangement | ucup-team4074# | Compile Error | / | / | C++98 | 2.5kb | 2024-10-07 15:24:48 | 2024-10-07 15:24:49 |
Judging History
This is the latest submission verdict.
- [2024-10-07 15:24:49]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-10-07 15:24:48]
- 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 <= cnt; i++) {
while (a[head].l <= now[i] && head <= n)q.push(head), head++;
if ((!q.empty()) && a[q.top()].r < now[i]) {
flag = 0;
}
for (int j = 1; j <= now[i]; j++) {
if (!q.empty())q.pop();
else flag = 0;
}
}
if (!q.empty() || head <= n)flag = 0;
return flag;
}
int sta_cnt(0);
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];
++cnt;
now[cnt] = i;
dfs(sum - i, i);
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
60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1 60
1234 124 2342 41 4 14 12 341 34 1 4 1
1234 124 2342 41 4 14 12 341 34 1 4 1
1234 124 2342 41 4 14 12 341 34 1 4 1
1234 124 2342 41 4 14 12 341 34 1 4 1
1234 124 2342 41 4 14 12 341 34 1 4 1
*/
详细
answer.code:37:41: error: ‘>>’ should be ‘> >’ within a nested template argument list 37 | priority_queue<int, vector<int>, CMP<int>> q; | ^~ | > >