QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#558135#8936. Team Arrangementleafmaple#WA 1ms7720kbC++201.0kb2024-09-11 14:24:322024-09-11 14:24:32

Judging History

This is the latest submission verdict.

  • [2024-09-11 14:24:32]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 7720kb
  • [2024-09-11 14:24:32]
  • Submitted

answer

#include <bits/stdc++.h>
#define xs(a) cout<<setiosflags(ios::fixed)<<setprecision(a);
#define endl '\n'
using namespace std;
using ll = long long;
const int N=1e6+5;
#define int long long

array<int,2>a[N];
int w[N];
int n, res=-1e18;
int vis[N];
void dfs(int u, int ans){
    if(u == n+1){
        for(int i=1; i<=n; i++)if(!vis[i])return ;
        res = max(res, ans);
        return ;
    }
    dfs(u+1, ans);
    int cnt = 0;
    vector<int>v;
    for(int i=1; i<=n && cnt <= u; i++)if(!vis[i]){
        if(a[i][0] <= u && a[i][1] >= u ){
            cnt ++;
            v.push_back(i);
        }
    }
    if(cnt == u){
        for(auto x: v)vis[x] = 1;
        dfs(u, ans + w[u]);
        for(auto x: v)vis[x] = 0;
    }
}

signed main(){
	cin.tie(0)->sync_with_stdio(0);
    cin >> n;
    for(int i=1; i<=n; i++) cin >> a[i][0] >> a[i][1];
    sort(a+1, a+1+n);
    for(int i=1; i<=n; i++) cin >> w[i];
    dfs(1, 0);
    if(res == -1e18) cout << "impossible" << endl;
    else cout << res << endl;
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 7588kb

input:

3
2 3
1 2
2 2
4 5 100

output:

9

result:

ok single line: '9'

Test #2:

score: 0
Accepted
time: 1ms
memory: 7696kb

input:

3
1 3
3 3
2 3
1 1 100

output:

100

result:

ok single line: '100'

Test #3:

score: 0
Accepted
time: 1ms
memory: 7720kb

input:

2
1 1
2 2
1 1

output:

impossible

result:

ok single line: 'impossible'

Test #4:

score: 0
Accepted
time: 1ms
memory: 7632kb

input:

3
2 3
1 2
2 2
-100 -200 100000

output:

-300

result:

ok single line: '-300'

Test #5:

score: -100
Wrong Answer
time: 1ms
memory: 7720kb

input:

9
1 4
2 5
3 4
1 5
1 1
2 5
3 5
1 3
1 1
1 1 1 1 1 1 1 1 1

output:

impossible

result:

wrong answer 1st lines differ - expected: '6', found: 'impossible'