QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#393022#2346. Miniature GolfnocrizAC ✓774ms4584kbC++141.7kb2024-04-18 03:31:302024-04-18 03:31:31

Judging History

This is the latest submission verdict.

  • [2024-04-18 03:31:31]
  • Judged
  • Verdict: AC
  • Time: 774ms
  • Memory: 4584kb
  • [2024-04-18 03:31:30]
  • Submitted

answer

#include <set>
#include <queue>
#include <cmath>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define debug(x) //cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

ll p,h,val[510][55];

int main() {
	read(p);read(h);
	for(int i=0;i<p;i++){
		for(int j=0;j<h;j++){
			read(val[i][j]);
		}
		sort(val[i],val[i]+h);
		val[i][h] = 1e10;
	}
	for(int i=0;i<p;i++){
		vector< pii > V;
		for(int j=0;j<p;j++){
			if(i == j)continue;
			ll a = 0,b = 0;
			ll sa = 0,sb = 0;
			//cout<<"Case #"<<i<<" : "<<j<<endl;
			while(!(a == h && b == h)){
				ll cv = min(val[i][a],val[j][b]);
				
				while(a!=h && val[i][a] == cv)sa+=cv,a++;
				while(b!=h && val[j][b] == cv)sb+=cv,b++;
				//cout<<"    "<<cv<<" a:"<<a<<" b:"<<b<<endl;
				debug(sa+cv*(h-a));
				debug(sb+cv*(h-b));
				ll nv = min(val[i][a],val[j][b]);
				debug(sa+nv*(h-a));
				debug(sb+nv*(h-b));
				if(sa+cv*(h-a)>=sb+cv*(h-b) && sa+nv*(h-a)<sb+nv*(h-b)){
					V.push_back(make_pair((sa-sb)/(a-b)+1,1));
				//	cout<<"    Add Pos"<<(sa-sb)/(a-b)+1<<endl;
				}
				if(sa+cv*(h-a)<sb+cv*(h-b) && sa+nv*(h-a)>=sb+nv*(h-b)){
					V.push_back(make_pair((sb-sa+b-a-1)/(b-a),-1));
				//	cout<<"    Sub Pos"<<(sb-sa+b-a-1)/(b-a)<<endl;
				}
			}
		}
		sort(V.begin(),V.end());
		ll ans = 0,cv = 0;
		for(auto ct:V){
			cv+=ct.second;
			ans = max(ans,cv);
		}
		cout<<p-ans<<'\n';
	}
	return 0;
}

Details

Test #1:

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

Test #2:

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

Test #3:

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

Test #4:

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

Test #5:

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

Test #6:

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

Test #7:

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

Test #8:

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

Test #9:

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

Test #10:

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

Test #11:

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

Test #12:

score: 0
Accepted
time: 3ms
memory: 3652kb

Test #13:

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

Test #14:

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

Test #15:

score: 0
Accepted
time: 3ms
memory: 3692kb

Test #16:

score: 0
Accepted
time: 7ms
memory: 3844kb

Test #17:

score: 0
Accepted
time: 774ms
memory: 4244kb

Test #18:

score: 0
Accepted
time: 737ms
memory: 4240kb

Test #19:

score: 0
Accepted
time: 686ms
memory: 4140kb

Test #20:

score: 0
Accepted
time: 278ms
memory: 4296kb

Test #21:

score: 0
Accepted
time: 266ms
memory: 4520kb

Test #22:

score: 0
Accepted
time: 278ms
memory: 4584kb

Test #23:

score: 0
Accepted
time: 192ms
memory: 3872kb

Test #24:

score: 0
Accepted
time: 193ms
memory: 3868kb

Test #25:

score: 0
Accepted
time: 191ms
memory: 3840kb

Test #26:

score: 0
Accepted
time: 191ms
memory: 3756kb

Test #27:

score: 0
Accepted
time: 192ms
memory: 3872kb