QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#553671#8936. Team Arrangementucup-team191#WA 0ms3876kbC++231.4kb2024-09-08 17:39:472024-09-08 17:39:47

Judging History

This is the latest submission verdict.

  • [2024-09-08 17:39:47]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3876kb
  • [2024-09-08 17:39:47]
  • Submitted

answer

#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using vl=vector<ll>;
#define pb push_back
#define all(a) begin(a),end(a)

const int N=310,MOD=1e9+7;
const char en='\n';
const ll LLINF=1ll<<60;

int n,w[N],cn[N][N];
pii h[N];
vi cu,pos,prs;
vector<pair<pair<vi,vi>,vi>> pars;

void rek(int s,int mi)
{
	if (s==0)
	{
		pos.pb(cu.size());
		prs.pb(n);
		pars.pb({{cu,pos},prs});
		pos.pop_back();
		prs.pop_back();
		return;
	}
	if (s<mi) return;
	for (int i=max(mi,1);i<=s;++i)
	{
		if (i!=mi) pos.pb(cu.size()),prs.pb(n-s);
		cu.pb(i);
		rek(s-i,i);
		cu.pop_back();
		if (i!=mi) pos.pop_back(),prs.pop_back();
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	rek(n,-1);
	for (int i=0;i<n;++i)
	{
		cin>>h[i].x>>h[i].y;
		for (int l=1;l<=n;++l) for (int r=l;r<=n;++r) if (r>=h[i].x && l<=h[i].y) ++cn[l][r];
	}
	for (int i=1;i<=n;++i) cin>>w[i];
	int an=-MOD;
	for (auto x: pars)
	{
		bool ok=1;
		const vi&pos=x.x.y;
		const vi&cu=x.x.x;
		const vi&prs=x.y;
		int posz=pos.size();
		for (int i=0;i<posz;++i) for (int j=i+1;j<posz;++j) if (cn[cu[pos[i]]][cu[pos[j]-1]]<prs[j]-prs[i]) ok=0;
		if (ok)
		{
			int ww=0;
			for (auto y: cu) ww+=w[y];
			an=max(an,ww);
		}
	}
	if (an==-MOD) cout<<"impossible"<<en;
	else cout<<an<<en;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

input:

3
1 3
3 3
2 3
1 1 100

output:

100

result:

ok single line: '100'

Test #3:

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

input:

2
1 1
2 2
1 1

output:

impossible

result:

ok single line: 'impossible'

Test #4:

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

input:

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

output:

-300

result:

ok single line: '-300'

Test #5:

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

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: 0
Accepted
time: 0ms
memory: 3608kb

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:

-16558567

result:

ok single line: '-16558567'

Test #7:

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

input:

14
1 2
1 4
2 3
3 5
4 5
2 5
2 4
2 4
1 2
3 4
1 5
2 4
1 1
4 5
-13763 -7354207 1096407 -9063321 -4824546 -6275546 1258145 -5272834 -8631107 3581157 2320771 -7714508 8446625 -6816167

output:

-2673021

result:

ok single line: '-2673021'

Test #8:

score: -100
Wrong Answer
time: 0ms
memory: 3612kb

input:

14
2 3
4 4
1 7
3 6
3 4
1 1
1 4
4 7
3 7
1 7
2 3
6 6
1 1
3 6
2923142 1686477 640352 2848353 9202543 -4441381 4866381 -3610520 8124124 -1372894 1111310 -7538627 466143 9937961

output:

10814681

result:

wrong answer 1st lines differ - expected: '5939733', found: '10814681'