Submission #1104428

# Submission time Handle Problem Language Result Execution time Memory
1104428 2024-10-23T18:09:23 Z alexander707070 Shortcut (IOI16_shortcut) C++14
0 / 100
1 ms 336 KB
#include<bits/stdc++.h>
#define MAXN 100007
using namespace std;

struct rect{
	long long minx,maxx;
	long long miny,maxy;

	inline friend rect operator + (rect fr,rect sc){
		return {max(fr.minx,sc.minx),min(fr.maxx,sc.maxx),max(fr.miny,sc.miny),min(fr.maxy,sc.maxy)};
	}
};

const long long inf=1e15;

int n,len[MAXN],d[MAXN],c;
long long pos[MAXN];

bool ok(long long fix){
	rect s={0,inf,0,inf},curr;

	for(int i=1;i<=n;i++){
		for(int f=i+1;f<=n;f++){
			if(pos[f]-pos[i]+d[i]+d[f]<=fix)continue;

			long long w=fix-d[i]-d[f]-c;
			if(w<0)return false;

			curr={pos[f]-pos[i]-w,pos[f]-pos[i]+w,pos[i]+pos[f]-w,pos[i]+pos[f]+w};
			s=s+curr;
		}
	}

	for(int i=1;i<=n;i++){
		for(int f=i+1;f<=n;f++){
			if(pos[f]-pos[i]>=s.minx and pos[f]-pos[i]<=s.maxx and pos[f]+pos[i]>=s.miny and pos[f]+pos[i]<=s.maxy)return true;
		}
	}

	return false;
}

long long find_shortcut(int N,vector<int> L,vector<int> D, int C){
	n=N; c=C;

	for(int i=1;i<=n-1;i++){
		len[i]=L[i-1];
		pos[i]=pos[i-1]+len[i-1];
	}

	for(int i=1;i<=n;i++){
		d[i]=D[i-1];
	}

	long long l=0,r=inf,tt;
	while(l+1<r){
		tt=(l+r)/2;
		if(ok(tt)){
			r=tt;
		}else{
			l=tt;
		}
	}

	return r;
}

/*int main(){

	cout<<find_shortcut(9, {10, 10, 10, 10, 10, 10, 10, 10},{20, 0, 30, 0, 0, 40, 0, 40, 0}, 30)<<"\n";

	return 0;
}*/
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB n = 4, incorrect answer: jury 80 vs contestant 60
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB n = 4, incorrect answer: jury 80 vs contestant 60
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB n = 4, incorrect answer: jury 80 vs contestant 60
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB n = 4, incorrect answer: jury 80 vs contestant 60
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB n = 4, incorrect answer: jury 80 vs contestant 60
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB n = 4, incorrect answer: jury 80 vs contestant 60
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB n = 4, incorrect answer: jury 80 vs contestant 60
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB n = 4, incorrect answer: jury 80 vs contestant 60
2 Halted 0 ms 0 KB -