답안 #292952

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
292952 2020-09-07T14:58:31 Z tmwilliamlin168 Shortcut (IOI16_shortcut) C++14
0 / 100
1 ms 384 KB
#include "shortcut.h"
#include <bits/stdc++.h>
using namespace std;

#define ll long long

ll find_shortcut(int n, vector<int> l, vector<int> d, int c) {
	vector<ll> x(n);
	for(int i=0; i+1<n; ++i)
		x[i+1]=x[i]+l[i];
	vector<int> e{n-1};
	for(int i=n-2; ~i; --i)
		if(d[i]-x[i]>d[e.back()]-x[e.back()])
			e.push_back(i);
	ll lb=1, rb=2e15;
	while(lb<rb) {
		ll mb=(lb+rb)/2, a1, a2=-1e18, a3=-1e18, b1=-1e18, b2=1e18, b3=-1e18, b4=1e18;
		for(int i=n-2, j=e.size()-1; ~i; --i) {
			if(i>(j?e[j-1]:-1)) {
				if(d[e[j]]+x[e[j]]+d[i]-x[i]>mb) {
					b1=max(c-mb+d[e[j]]+x[e[j]]+d[i]+x[i], b1);
					b2=min(mb-c-d[e[j]]+x[e[j]]-d[i]+x[i], b2);
					b3=max(c-mb+d[e[j]]-x[e[j]]+d[i]+x[i], b3);
					b4=min(mb-c-d[e[j]]-x[e[j]]-d[i]+x[i], b4);
				}
			} else
				--j;
		}
		for(int i=e.size()-1, j=0; j<n;) {
			a1=d[j]+x[j];
			for(; ~i&&e[i]<j&&a1+d[e[i]]-x[e[i]]>mb; --i) {
				a2=max(d[e[i]]+x[e[i]], a2);
				a3=max(d[e[i]]-x[e[i]], a3);
			}
			b1=max(c-mb+a1+a2, b1);
			b2=min(mb-c-d[j]+x[j]-a3, b2);
			b3=max(c-mb+d[j]-x[j]+a2, b3);
			b4=min(mb-c-a1-a3, b4);
			for(int k=j; ++j<n&&d[j]+x[j]<a1;) {
				if(d[j]+x[j]+d[k]-x[k]>mb) {
					b1=max(c-mb+d[j]+x[j]+d[k]+x[k], b1);
					b2=min(mb-c-d[j]+x[j]-d[k]+x[k], b2);
					b3=max(c-mb+d[j]-x[j]+d[k]+x[k], b3);
					b4=min(mb-c-d[j]-x[j]-d[k]+x[k], b4);
				}
			}
		}
		bool ok=0;
		for(int i=0, j1=n, j2=n, j3=0, j4=0; i<n; ++i) {
			for(; j1&&x[j1-1]>=b1-x[i]; --j1);
			for(; j2&&x[j2-1]>b2-x[i]; --j2);
			for(; j3<n&&x[j3]<b3+x[i]; ++j3);
			for(; j4<n&&x[j4]<=b4+x[i]; ++j4);
			ok|=max(j1, j3)<min(j2, j4);
		}
		if(ok)
			rb=mb;
		else
			lb=mb+1;
	}
	return lb;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB n = 4, 80 is a correct answer
2 Correct 1 ms 256 KB n = 9, 110 is a correct answer
3 Correct 1 ms 256 KB n = 4, 21 is a correct answer
4 Correct 1 ms 368 KB n = 3, 4 is a correct answer
5 Correct 1 ms 256 KB n = 2, 62 is a correct answer
6 Correct 1 ms 384 KB n = 2, 3 is a correct answer
7 Incorrect 1 ms 256 KB n = 3, incorrect answer: jury 29 vs contestant 20
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB n = 4, 80 is a correct answer
2 Correct 1 ms 256 KB n = 9, 110 is a correct answer
3 Correct 1 ms 256 KB n = 4, 21 is a correct answer
4 Correct 1 ms 368 KB n = 3, 4 is a correct answer
5 Correct 1 ms 256 KB n = 2, 62 is a correct answer
6 Correct 1 ms 384 KB n = 2, 3 is a correct answer
7 Incorrect 1 ms 256 KB n = 3, incorrect answer: jury 29 vs contestant 20
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB n = 4, 80 is a correct answer
2 Correct 1 ms 256 KB n = 9, 110 is a correct answer
3 Correct 1 ms 256 KB n = 4, 21 is a correct answer
4 Correct 1 ms 368 KB n = 3, 4 is a correct answer
5 Correct 1 ms 256 KB n = 2, 62 is a correct answer
6 Correct 1 ms 384 KB n = 2, 3 is a correct answer
7 Incorrect 1 ms 256 KB n = 3, incorrect answer: jury 29 vs contestant 20
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB n = 4, 80 is a correct answer
2 Correct 1 ms 256 KB n = 9, 110 is a correct answer
3 Correct 1 ms 256 KB n = 4, 21 is a correct answer
4 Correct 1 ms 368 KB n = 3, 4 is a correct answer
5 Correct 1 ms 256 KB n = 2, 62 is a correct answer
6 Correct 1 ms 384 KB n = 2, 3 is a correct answer
7 Incorrect 1 ms 256 KB n = 3, incorrect answer: jury 29 vs contestant 20
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB n = 4, 80 is a correct answer
2 Correct 1 ms 256 KB n = 9, 110 is a correct answer
3 Correct 1 ms 256 KB n = 4, 21 is a correct answer
4 Correct 1 ms 368 KB n = 3, 4 is a correct answer
5 Correct 1 ms 256 KB n = 2, 62 is a correct answer
6 Correct 1 ms 384 KB n = 2, 3 is a correct answer
7 Incorrect 1 ms 256 KB n = 3, incorrect answer: jury 29 vs contestant 20
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB n = 4, 80 is a correct answer
2 Correct 1 ms 256 KB n = 9, 110 is a correct answer
3 Correct 1 ms 256 KB n = 4, 21 is a correct answer
4 Correct 1 ms 368 KB n = 3, 4 is a correct answer
5 Correct 1 ms 256 KB n = 2, 62 is a correct answer
6 Correct 1 ms 384 KB n = 2, 3 is a correct answer
7 Incorrect 1 ms 256 KB n = 3, incorrect answer: jury 29 vs contestant 20
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB n = 4, 80 is a correct answer
2 Correct 1 ms 256 KB n = 9, 110 is a correct answer
3 Correct 1 ms 256 KB n = 4, 21 is a correct answer
4 Correct 1 ms 368 KB n = 3, 4 is a correct answer
5 Correct 1 ms 256 KB n = 2, 62 is a correct answer
6 Correct 1 ms 384 KB n = 2, 3 is a correct answer
7 Incorrect 1 ms 256 KB n = 3, incorrect answer: jury 29 vs contestant 20
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB n = 4, 80 is a correct answer
2 Correct 1 ms 256 KB n = 9, 110 is a correct answer
3 Correct 1 ms 256 KB n = 4, 21 is a correct answer
4 Correct 1 ms 368 KB n = 3, 4 is a correct answer
5 Correct 1 ms 256 KB n = 2, 62 is a correct answer
6 Correct 1 ms 384 KB n = 2, 3 is a correct answer
7 Incorrect 1 ms 256 KB n = 3, incorrect answer: jury 29 vs contestant 20
8 Halted 0 ms 0 KB -