QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#665808#8936. Team ArrangementxuzhihaodedieWA 1ms5928kbC++201.3kb2024-10-22 15:24:012024-10-22 15:24:01

Judging History

This is the latest submission verdict.

  • [2024-10-22 15:24:01]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5928kb
  • [2024-10-22 15:24:01]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PII pair<int,int>
#define lson 2*p
#define rson 2*p+1
#define x first
#define y second
// #define endl "\n"
const int N=2e5+10;
const int mod=1e9+7;
vector<int> v;
int ans=-1e18;
int w[N];
PII p[N];
bool cmp(PII a,PII b) {
	return a.y<b.y;
}
int n;
void dfs(int now,int last) {
	if(now==n) {
		priority_queue<PII,vector<PII>,greater<PII> > q;
		int pos=0;
		// for(int x:v) cout<<x<<" ";
		// cout<<endl;
		for(int x:v) {
			while(pos+1<=n&&p[pos+1].y>=x) pos++,q.push({p[pos].x,pos});
			if(q.size()<x) return ;
			for(int i=1;i<=x;i++) {
				auto [y,z]=q.top();
				q.pop();
				if(y>x) return ;
			}
		}
		int val=0;
		for(int x:v) val+=w[x];	
		ans=max(ans,val);
		return ;
	}
	for(int i=last;i<=n-now;i++) {
		v.push_back(i);
		dfs(now+i,i);
		v.pop_back();
	}
}
void solve() {
	cin>>n;
	for(int i=1;i<=n;i++) cin>>p[i].x>>p[i].y;
	for(int i=1;i<=n;i++) cin>>w[i];
	sort(p+1,p+n+1,cmp);
	double st=clock();
	dfs(0,1);
	double ed=clock();
	if(ans==-1e18) {
		cout<<"impossible"<<endl;
		return ;
	}
	cout<<ans<<endl;
	// cout<<ed-st<<endl;
} 
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int T=1;
	// cin>>T;
	while(T--) {
		solve();
	}
}

详细

Test #1:

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

input:

3
2 3
1 2
2 2
4 5 100

output:

9

result:

ok single line: '9'

Test #2:

score: 0
Accepted
time: 0ms
memory: 5636kb

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

input:

2
1 1
2 2
1 1

output:

impossible

result:

ok single line: 'impossible'

Test #4:

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

input:

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

output:

-300

result:

ok single line: '-300'

Test #5:

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

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:

6

result:

ok single line: '6'

Test #6:

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

input:

14
3 3
1 2
2 3
2 3
2 3
1 1
2 3
1 3
3 3
1 3
1 3
1 2
2 3
1 3
-9807452 -9610069 4156341 2862447 6969109 -7245265 -2653530 -5655094 6467527 -6872459 3971784 7312155 9766298 -2719573

output:

8287107

result:

wrong answer 1st lines differ - expected: '-16558567', found: '8287107'