ICPC 2017 - H. Scenery
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/2017/H-scenery. Edit
competitive_programming/icpc/2017/H-scenery/solution.tex to update the written solution and
competitive_programming/icpc/2017/H-scenery/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.
Rapid City
event
sponsor
ICPC 2017
Problem H
Scenery
Time limit: 6 seconds
Images by John Fowler, Carol Highsmith, and Richard Woodland
You have decided to spend a day of your trip to Rapid City taking photographs of the South Dakota Badlands,
which are renowned for their spectacular and unusual land formations. You are an amateur photographer,
yet very particular about lighting conditions.
After some careful research, you have located a beautiful location in the Badlands, surrounded by pic-
turesque landscapes. You have determined a variety of features that you wish to photograph from this
location. For each feature you have identified the earliest and latest time of day at which the position of
the sun is ideal. However, it will take quite a bit of time to take each photograph, given the need to repo-
sition the tripod and camera and your general perfectionism. So you are wondering if it will be possible to
successfully take photographs of all these features in one day.
Input
The first line of the input contains two integers n (1 ≤ n ≤ 104 ) and t (1 ≤ t ≤ 105 ), where n is the number
of desired photographs and t is the time you spend to take each photograph. Following that are n additional
lines, each describing the available time period for one of the photographs. Each such line contains two
nonnegative integers a and b, where a is the earliest time that you may begin working on that photograph,
and b is the time by which the photograph must be completed, with a + t ≤ b ≤ 109 .
Output
Display yes if it is possible to take all n photographs, and no otherwise.
Rapid City
event
sponsor
ICPC 2017
Sample Input 1 Sample Output 1
2 10 yes
0 15
5 20
Sample Input 2 Sample Output 2
2 10 no
1 15
0 20
Sample Input 3 Sample Output 3
2 10 yes
5 30
10 20
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 2017\\H. Scenery}
\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;
}