QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#541561#8936. Team Arrangementucup-team3474#WA 1ms5864kbC++201.3kb2024-08-31 20:00:292024-08-31 20:00:30

Judging History

This is the latest submission verdict.

  • [2024-08-31 20:00:30]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5864kb
  • [2024-08-31 20:00:29]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
const int N=5e5+10;
typedef long long ll;
typedef pair<ll,ll> PII;
ll n,m,k;
ll a[N],b[N];
PII e[N];
int cnt=0;
ll ans=-1e18;
ll w[N];
vector<PII> v;

void dfs(int x,int sum,ll val){
    // cout<<x<<" "<<sum<<" "<<val<<endl;
	if(x==0){
		// cnt++;
        vector<int> vv;
        for(int i=v.size()-1;i>=0;i--){
            for(int j=1;j<=v[i].second;j++){
                vv.push_back(v[i].first);
            }
        }
        int j=1;
        for(int i=0;i<vv.size();i++){
            int k=1;
            while(k<=vv[i]){
                if(vv[i]>=e[j].second&&vv[i]<=e[j].first){
                    j++;
                    k++;
                }else return;
            }
        }
        ans=max(ans,val);
	}else{
        if(x==1){
            v.push_back({1,n-sum});
            dfs(x-1,n,val+(n-sum)*w[1]);
            v.pop_back();
            return;
        }
		for(int i=0;i<=n;i++){
			if(sum+i*x>n) break;
            v.push_back({x,i});
			dfs(x-1,sum+i*x,val+w[x]*i);
            v.pop_back();
        }
	}
}


int main(){
	cin>>n;
    for(int i=1;i<=n;i++){
        cin>>e[i].second>>e[i].first;
    }
    for(int i=1;i<=n;i++) cin>>w[i];
    sort(e+1,e+1+n);
	dfs(n,0,0);
    if(ans<-1e13) puts("impossible");
    else
    cout<<ans<<endl;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5788kb

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: 5864kb

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: 5808kb

input:

2
1 1
2 2
1 1

output:

impossible

result:

ok single line: 'impossible'

Test #4:

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

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: 5648kb

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:

5

result:

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