atcoder ABC113 C problem

When doing competitive programming, I often hold two values (such as a person's name and year), and this time it was a problem that could not be solved without using such a data structure, so what is a map? A memo instead of a review. https://atcoder.jp/contests/abc113/tasks/abc113_c

What is map

A map, also known as an associative array, is a collection that can hold keys and values (a data structure that can be resized later). Do not allow duplicate keys.

map type

HashMap order is appropriate HashTable key in descending order TreeMap key in ascending order

How to solve this problem

This time, the number of the prefecture to which the city belongs and the year of birth of the city are given, and considering that the year of birth does not overlap, if you put the year of birth as the key and the prefecture to which you belong as the value in the Treemap, you will be born. Since it is sorted by year, you can update the order for each prefecture in the array. Also, the operation of packing 0s from the left with 6 digits is as follows.

Example



System.out.println(String.format("%06d",  1);

result



000001

Citation, reference https://www.sejuku.net/blog/16055 http://kaworu.jpn.org/kaworu/2008-04-10-2.php

Recommended Posts

atcoder ABC113 C problem
atcoder ABC115 C problem
atcoder ABC70 D problem
AtCoder Beginner Contest 167 C Problem (Java)
ABC --013-A & B & C
ABC --023 --A & B & C
ABC --036-A & B & C
ABC --028 --A & B & C
ABC --015 --A & B & C
ABC --128 --A & B & C
ABC --012-A & B & C
ABC093 C --Same Integers
ABC --018 --A & B & C
AtCoder ABC 169 C Floating Point Fits in Ruby
ABC --054 --A & B & C
ABC --017 --A & B & C
ABC --029- A & B & C
ABC --022 --A & B & C
ABC --019 --A & B & C
ABC --020 --A & B & C
ABC --030- A & B & C
ABC --127 --A & B & C
ABC --007 --A & B & C
ABC --132- A & B & C
ABC --026 --A & B & C
ABC --014- A & B & C
ABC --016 --A & B & C
ABC --011-A & B & C
ABC --031 --A & B & C
ABC --021 --A & B & C
ABC --025 --A & B & C
ABC --024 --A & B & C
ABC --027 --A & B & C
ABC --080- A & B & C
Solving with Ruby, Perl and Java AtCoder ABC 128 C
ABC --129- A & B & C & D
ABC --133- A & B & C & D
ABC --122 --A & B & C & D
AtCoder Beginner Contest 132 D Problem
ABC --125- A & B & C & D
ABC --130- A & B & C & D
ABC --126 --A & B & C & D
Solving in Ruby, Perl and Java AtCoder ABC 113 C Reference
Solving with Ruby, Perl and Java AtCoder ABC 129 C (Part 1)
ABC --134- A & B & C & D & E
ABC --131- A & B & C & D & E
Sorting AtCoder ABC 111 C hashes to solve in Ruby, Perl and Java
Solving with Ruby, Perl and Java AtCoder ABC 129 C (Part 2) Dynamic programming
Solve with Ruby AtCoder ABC177 D UnionFind
Getter, Setter Inverse Problem-10 [C # Refactoring Sample]
[Code] Forcibly breaks through the C problem "* 3 or / 2" of [AtCoder Problem-ABC100] with Java [Code]