QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#523737#6770. AntsazWA 99ms54280kbC++201.4kb2024-08-18 17:15:322024-08-18 17:15:32

Judging History

This is the latest submission verdict.

  • [2024-08-18 17:15:32]
  • Judged
  • Verdict: WA
  • Time: 99ms
  • Memory: 54280kb
  • [2024-08-18 17:15:32]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
//#define endl "\n"
#define PII pair<int,int>
#define PIS pair<int,string>
#define fr(i,xxx,yyy) for(int i=xxx,ppp=yyy;i<=ppp;i++)
#define rp(i,xxx,yyy) for(int i=xxx,ppp=yyy;i>=ppp;i--)
const int N=1e6+10;
const int M=1e9+1;
int mod=998244353;
int a[N],b[N],c[N],d[N],l[N],r[N];
int f[N];
void solve() {
	int n,p,q;
	cin>>n>>p>>q;
	fr(i,1,n) {
		cin>>a[i];
	}
	int na=0,nb=0;
	fr(i,1,n) {
		cin>>b[i];
		if(b[i]==1)r[nb++]=M-a[i];
		else l[na++]=a[i];
	}
	int t=0;
	int num=min((p+n-1)/n,(q+n-1)/n);
	t+=2*M*(num-1);
	p-=n*(num-1);
	q-=n*(num-1);
	int ans=n;
	sort(l,l+na);
	sort(r,r+nb);
	fr(i,1,na){
		b[i]=0;
		d[i]=l[i-1];
	}fr(i,na+1,na+nb){
		b[i]=1;
		d[i]=r[i-na-1];
		d[i]=M-d[i];
	}
	
	while(ans) {
		fr(i,1,n) {
			if(f[i])continue;
			if(b[i]==0) {
				int s=d[i];
				d[i]=0;
				c[i]+=s;
				b[i]=1;
				if(p==0) {
					f[i]=1;
					ans--;
					if(ans==0)t+=c[i];
					continue;
				}
				p--;
			}
			else if(b[i]==1) {
				int s=M-d[i];
				d[i]=M;
				c[i]+=s;
				b[i]=0;
				if(q==0) {
					f[i]=1;
					ans--;
					if(ans==0)t+=c[i];
					continue;
				}
				q--;
			}
		}
	}cout<<t;
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int n=1;
	//cin>>n;
	while(n--)
		solve();
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 2ms
memory: 13936kb

input:

2 2 4
2 3
0 1

output:

4000000001

result:

ok single line: '4000000001'

Test #2:

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

input:

1 1000000000 1000000000
500000000
0

output:

2000000002500000000

result:

ok single line: '2000000002500000000'

Test #3:

score: 0
Accepted
time: 2ms
memory: 11876kb

input:

1 1000000000 500000000
500000000
1

output:

1000000001500000001

result:

ok single line: '1000000001500000001'

Test #4:

score: 0
Accepted
time: 2ms
memory: 11876kb

input:

1 500000000 1000000000
500000000
0

output:

1000000001500000000

result:

ok single line: '1000000001500000000'

Test #5:

score: -100
Wrong Answer
time: 99ms
memory: 54280kb

input:

999963 1000000000 1000000000
516 793 2609 2721 3010 3378 4494 6294 7719 9298 9582 10021 10255 13552 16357 16771 16864 18824 19006 19162 19583 22099 22970 23637 25760 26962 29349 31140 34093 34398 35622 35765 35868 35899 36213 37137 38062 43181 43361 44347 46328 48145 48188 49187 50303 50873 52999 53...

output:

2001073756444

result:

wrong answer 1st lines differ - expected: '2001074431727', found: '2001073756444'