Submission #784746

# Submission time Handle Problem Language Result Execution time Memory
784746 2023-07-16T13:21:46 Z aymanrs Shortcut (IOI16_shortcut) C++14
0 / 100
1 ms 224 KB
#include<bits/stdc++.h>
using namespace std;
long long find_shortcut(int n, vector<int> l, vector<int> d, int c){
	long long L = 1, R = (long long)1e9 * n, M, B = R;
	long long t[n];
	vector<pair<long long, long long>> mtd[n];
	vector<long long> smin[n];
	t[0] = 0;
	for(int i = 1;i < n;i++) t[i] = l[i-1]+t[i-1];
	for(int i = 0;i < n;i++){
		for(int j = i+1;j < n;j++){
			mtd[i].emplace_back(t[j]+d[j], t[j]-d[j]);
		}
		sort(mtd[i].begin(), mtd[i].end());
		smin[i].resize(mtd[i].size());
		long long nex = LONG_LONG_MAX;
		for(int j = n-1;j > i;j--){
			nex = smin[i][j-i-1] = min(mtd[i][j-i-1].second, nex);
		}
	}
	while(L <= R){
		M = L+(R-L)/2;
		bool ok = false;
		for(int i = 0;i < n;i++){
			long long le = 0, re = LONG_LONG_MAX;
			for(int j = 0;j < n;j++){
				if(mtd[j].empty() || mtd[j].back().first-t[j]+d[j] <= M) continue;
				le = max(le, abs(t[j]-t[i])+mtd[j].back().first+d[j]+c-M);
				int p = lower_bound(mtd[j].begin(), mtd[j].end(), make_pair(M+t[j]-d[j]+1, LONG_LONG_MIN))-mtd[j].begin();
				re = min(re, smin[j][p]-abs(t[j]-t[i])-d[j]+M-c);
			}
			for(int j=0;j < n;j++) ok |= le <= t[j] && t[j] <= re;
		}
		if(ok) {
			R = M-1;
			B = M;
		} else L = M+1;
	}
	return B;
}
// 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';
// }
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB n = 4, 80 is a correct answer
2 Correct 1 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Correct 0 ms 212 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 1 ms 224 KB n = 3, 29 is a correct answer
8 Correct 1 ms 212 KB n = 2, 3 is a correct answer
9 Correct 1 ms 212 KB n = 2, 3 is a correct answer
10 Incorrect 1 ms 212 KB n = 2, incorrect answer: jury 2000000001 vs contestant 2000000000
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB n = 4, 80 is a correct answer
2 Correct 1 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Correct 0 ms 212 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 1 ms 224 KB n = 3, 29 is a correct answer
8 Correct 1 ms 212 KB n = 2, 3 is a correct answer
9 Correct 1 ms 212 KB n = 2, 3 is a correct answer
10 Incorrect 1 ms 212 KB n = 2, incorrect answer: jury 2000000001 vs contestant 2000000000
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB n = 4, 80 is a correct answer
2 Correct 1 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Correct 0 ms 212 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 1 ms 224 KB n = 3, 29 is a correct answer
8 Correct 1 ms 212 KB n = 2, 3 is a correct answer
9 Correct 1 ms 212 KB n = 2, 3 is a correct answer
10 Incorrect 1 ms 212 KB n = 2, incorrect answer: jury 2000000001 vs contestant 2000000000
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB n = 4, 80 is a correct answer
2 Correct 1 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Correct 0 ms 212 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 1 ms 224 KB n = 3, 29 is a correct answer
8 Correct 1 ms 212 KB n = 2, 3 is a correct answer
9 Correct 1 ms 212 KB n = 2, 3 is a correct answer
10 Incorrect 1 ms 212 KB n = 2, incorrect answer: jury 2000000001 vs contestant 2000000000
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB n = 4, 80 is a correct answer
2 Correct 1 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Correct 0 ms 212 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 1 ms 224 KB n = 3, 29 is a correct answer
8 Correct 1 ms 212 KB n = 2, 3 is a correct answer
9 Correct 1 ms 212 KB n = 2, 3 is a correct answer
10 Incorrect 1 ms 212 KB n = 2, incorrect answer: jury 2000000001 vs contestant 2000000000
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB n = 4, 80 is a correct answer
2 Correct 1 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Correct 0 ms 212 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 1 ms 224 KB n = 3, 29 is a correct answer
8 Correct 1 ms 212 KB n = 2, 3 is a correct answer
9 Correct 1 ms 212 KB n = 2, 3 is a correct answer
10 Incorrect 1 ms 212 KB n = 2, incorrect answer: jury 2000000001 vs contestant 2000000000
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB n = 4, 80 is a correct answer
2 Correct 1 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Correct 0 ms 212 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 1 ms 224 KB n = 3, 29 is a correct answer
8 Correct 1 ms 212 KB n = 2, 3 is a correct answer
9 Correct 1 ms 212 KB n = 2, 3 is a correct answer
10 Incorrect 1 ms 212 KB n = 2, incorrect answer: jury 2000000001 vs contestant 2000000000
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB n = 4, 80 is a correct answer
2 Correct 1 ms 212 KB n = 9, 110 is a correct answer
3 Correct 0 ms 212 KB n = 4, 21 is a correct answer
4 Correct 0 ms 212 KB n = 3, 4 is a correct answer
5 Correct 0 ms 212 KB n = 2, 62 is a correct answer
6 Correct 0 ms 212 KB n = 2, 3 is a correct answer
7 Correct 1 ms 224 KB n = 3, 29 is a correct answer
8 Correct 1 ms 212 KB n = 2, 3 is a correct answer
9 Correct 1 ms 212 KB n = 2, 3 is a correct answer
10 Incorrect 1 ms 212 KB n = 2, incorrect answer: jury 2000000001 vs contestant 2000000000
11 Halted 0 ms 0 KB -