ICPC 2014 - J. Skiing
State the problem in your own words. Focus on the mathematical or algorithmic core rather than repeating the full statement.
Source-first archive entry
This page is built from the copied files in competitive_programming/icpc/2014/J-skiing. Edit
competitive_programming/icpc/2014/J-skiing/solution.tex to update the written solution and
competitive_programming/icpc/2014/J-skiing/solution.cpp to update the implementation.
The website does not replace those files with hand-maintained HTML. It reads the copied source tree during the build and exposes the exact files below.
Problem Statement
Copied statement text kept beside the solution archive for direct reference.
Problem J
Skiing
Time Limit: 2 seconds
As you know, the ACM ICPC is not the only major sporting event taking place in Russia this year.
Several months ago, the 2014 Winter Olympics were held in Sochi, which is about 3 000 km from
Ekaterinburg.
In an increasing number of sports, it is not only the ability of the athletes that determines who wins a
competition but also their equipment. For example in downhill skiing, having the latest ski technology
enables athletes to increase their speeds and improve their turning ability.
You have been hired to determine the effect of the latest ski technology on the ability of skiers to navigate
a downhill course. The course contains several target locations, and the skier wants to pass over as many
of them as possible. Naturally, the better the ski technology, the easier it will be to do this.
For simplicity, use a two-dimensional coordinate system where the skier starts at position (0,0) and
where “downhill” corresponds to the direction of the positive y-axis.
Assume the y-component of the athlete’s velocity is a constant vy . The athlete can change speed laterally
(in the x-direction), but the skiing equipment limits this to a maximal lateral acceleration amax . The skier
starts with a lateral velocity of 0.
y
Skier’s path
x
(0,0)
Figure J.1: Downhill ski path passing over three targets
In Figure J.1 (which corresponds to the first sample input), the optimal path passes over three out of four
possible targets. If amax were smaller, then the skier might be able to pass over only two or fewer of the
targets.
Input
The input contains a single test case. The first line contains three integers n, vy , and amax (0 ≤ n ≤ 250,
0 ≤ vy ≤ 105 and 0 ≤ amax ≤ 107 ), where n is the number of targets, vy is the y-component of the
skier’s velocity, and amax is the maximum lateral acceleration. Here vy is given in meters per hour and
amax in meters per hour squared.
Following this are n lines, each containing two integers xi and yi (−105 ≤ xi , yi ≤ 105 ). These give
the coordinates of each target to be visited on the course. All coordinates are given in meters. Targets
are numbered 1, 2, ..., n in the order they are given.
Output
Display the maximal-length sequence of targets that the athlete could pass over on the course in a single
run. Display the targets in the order they are visited. If there are multiple maximal-length sequences,
display only the lexicographically first one. (So the sequence 2 15 would come before the sequence
10 15.) If the athlete cannot pass over any targets, print Cannot visit any targets instead.
To ensure floating-point stability, you may assume the answer will not change if amax is perturbed by
up to 0.1.
Sample Input 1 Sample Output 1
4 100 400 1 2 4
-100 100
50 200
-100 300
150 300
Sample Input 2 Sample Output 2
1 100 100 Cannot visit any targets
1000 10
Editorial
Rendered from the copied solution.tex file. The original TeX source remains
available below.
Key Observations
Write the structural observations that make the problem tractable.
State any useful invariant, monotonicity property, graph interpretation, or combinatorial reformulation.
If the constraints matter, explain exactly which part of the solution they enable.
Algorithm
Describe the data structures and the state maintained by the algorithm.
Explain the processing order and why it is sufficient.
Mention corner cases explicitly if they affect the implementation.
Correctness Proof
We prove that the algorithm returns the correct answer.
Lemma 1.
State the first key claim.
Proof.
Provide a concise proof.
Lemma 2.
State the next claim if needed.
Proof.
Provide a concise proof.
Theorem.
The algorithm outputs the correct answer for every valid input.
Proof.
Combine the lemmas and finish the argument.
Complexity Analysis
State the running time and memory usage in terms of the input size.
Implementation Notes
Mention any non-obvious implementation detail that is easy to get wrong.
Mention numeric limits, indexing conventions, or tie-breaking rules if relevant.
Code
Exact copied C++ implementation from solution.cpp.
#include <bits/stdc++.h>
using namespace std;
namespace {
void solve() {
// Fill in the full solution logic for the problem here.
}
} // namespace
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}
Source Files
Exact copied source-of-truth files. Edit solution.tex for the write-up and solution.cpp for the implementation.
\documentclass[11pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{enumitem}
\title{ICPC World Finals 2014\\J. Skiing Time Limit: 2 seconds}
\author{}
\date{}
\begin{document}
\maketitle
\section*{Problem Summary}
State the problem in your own words. Focus on the mathematical or algorithmic core rather than repeating the full statement.
\section*{Key Observations}
\begin{itemize}[leftmargin=*]
\item Write the structural observations that make the problem tractable.
\item State any useful invariant, monotonicity property, graph interpretation, or combinatorial reformulation.
\item If the constraints matter, explain exactly which part of the solution they enable.
\end{itemize}
\section*{Algorithm}
\begin{enumerate}[leftmargin=*]
\item Describe the data structures and the state maintained by the algorithm.
\item Explain the processing order and why it is sufficient.
\item Mention corner cases explicitly if they affect the implementation.
\end{enumerate}
\section*{Correctness Proof}
We prove that the algorithm returns the correct answer.
\paragraph{Lemma 1.}
State the first key claim.
\paragraph{Proof.}
Provide a concise proof.
\paragraph{Lemma 2.}
State the next claim if needed.
\paragraph{Proof.}
Provide a concise proof.
\paragraph{Theorem.}
The algorithm outputs the correct answer for every valid input.
\paragraph{Proof.}
Combine the lemmas and finish the argument.
\section*{Complexity Analysis}
State the running time and memory usage in terms of the input size.
\section*{Implementation Notes}
\begin{itemize}[leftmargin=*]
\item Mention any non-obvious implementation detail that is easy to get wrong.
\item Mention numeric limits, indexing conventions, or tie-breaking rules if relevant.
\end{itemize}
\end{document}
#include <bits/stdc++.h>
using namespace std;
namespace {
void solve() {
// Fill in the full solution logic for the problem here.
}
} // namespace
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}