task
stringlengths
0
154k
__index_level_0__
int64
0
39.2k
B: 党日本垰りたい協䌚 問題 株匏䌚瀟 AOR (Association Of Return home)には $N$ 人の瀟員がいる。 瀟員 $i$ ぱレベヌタヌを䜿っお $1$ 階に䞋りたいず考えおおり、時刻 $t_i$ に $F_i$ 階の゚レベヌタヌ前にやっおくる。あなたは時刻 $0$ に $1$ 階に $1$ 基だけある゚レベヌタヌを遠隔操䜜し、すべおの瀟員を $1$ 階に送るこずにした。゚レベヌタヌには $D$ 人たでしか乗せられない。 ゚レベヌタヌは単䜍時間に䞀階分移動するかその堎にずどたる事ができる。 瀟員 $i$ ぱレベヌタヌが時刻 $t_i$ に $F_i$ 階にあっお、自分が乗っおも定員を超過しないずきのみ...
35,400
Score: 300 points Problem Statement As AtCoder Beginner Contest 100 is taking place, the office of AtCoder, Inc. is decorated with a sequence of length N , a = { a_1, a_2, a_3, ..., a_N }. Snuke, an employee, would like to play with this sequence. Specifically, he would like to repeat the following operation as many ti...
35,401
Problem E: Immortal Jewels English text is not available in this practice contest. ある時ある貎族がある貧乏な囜のおおんばで勇敢なお姫様に惚れ蟌み結婚を申し蟌んだお姫様は貎族にある条件を出したその条件ずは「䞍死の宝石」ず呌ばれおいる宝石を倧量に持っおくるこずであった䞍死の宝石はある山の特定の堎所でしか取るこずができない非垞に垌少な宝石であるしかも倧倉壊れやすいため採取するには特別な方法が必芁だった 䞍死の宝石は円圢をしおおり二次元空間䞊に耇数存圚しおいるこの宝石を取るにはある特別な金属の棒でそれらを吞着する必芁がある金属の棒は無...
35,402
Score : 600 points Problem Statement Given are two integer sequences of N elements each: A_1,...,A_N and B_1,...,B_N . Determine if it is possible to do the following operation at most N-2 times (possibly zero) so that, for every integer i from 1 to N , A_i \leq B_i holds: Choose two distinct integers x and y between 1...
35,403
Score : 300 points Problem Statement You are given an integer N . For two positive integers A and B , we will define F(A,B) as the larger of the following: the number of digits in the decimal notation of A , and the number of digits in the decimal notation of B . For example, F(3,11) = 2 since 3 has one digit and 11 ha...
35,404
n 個の郜垂ず n − 1 本の道路があり朚になっおいる郜垂には 1 から n たでの番号が぀けられおいる郜垂 1 を根ずみたずき郜垂 i の芪は p i であり i ず p i の距離は d i であるすぬけ君は1 以䞊 n 以䞋の各 k に察し次の問題を解きたい ある郜垂から郜垂 1, . . . . , k ぞの距離の和の最小倀 \begin{eqnarray} min_{1 \leq v \leq n} \{ \sum^k_{i=1} dist(i, v)\} \;\;\;\;\;\;\;\;\;\;\;\;\;\;(2) \end{eqnarray} を求めよただし dist(u, v) は u ず v...
35,405
問題 䞭孊校の運動䌚で次のようなクラス察抗の競技を行なうこずになった 各クラスから生埒代衚の男女 n ペア (男子生埒 b 1  女子生埒 g 1 ) (男子生埒 b 2  女子生埒 g 2 ) 
  (男子生埒 b n  女子生埒 g n ) を遞び 0 から 9 たでの数字が曞かれた旗を自由に遞んでもらい それぞれの旗は十分な個数ある 暪䞀列に䞊んでもらう ただし ペアになっおいる男子生埒ず女子生埒は同じ番号の旗を䞀人぀ず぀ 遞ばなければならず 䞊び順は b 1 b 2 
 b n c g n 
 g 2 g 1 のように 男子生埒達 n 人の䞊び順 b 1 b 2 
 b n ずは逆の順番 ...
35,406
Score : 100 points Problem Statement You are given an integer K . Print the string obtained by repeating the string ACL K times and concatenating them. For example, if K = 3 , print ACLACLACL . Constraints 1 \leq K \leq 5 All values in input are integers. Input Input is given from Standard Input in the following format...
35,407
理想の䜓型 肥満床を衚す指数ずしおBMIBody Mass Indexがありたす。BMIの倀は以䞋の匏で蚈算したす。 BMI = 䜓重(kg) / (身長(m)) 2 BMIの倀が暙準倀に近いほど「理想の䜓型」ず考えられたす。そこで、BMIの暙準倀を 22 ずした堎合、察象者の情報を入力ずし、最も「理想の䜓型」に近い人の情報を出力するプログラムを䜜成しおください。 察象者の数を n ずするず、各察象者には重耇のないように1 以䞊 n 以䞋の敎数倀の受付番号 p が振られおいたす。 Input 耇数のデヌタセットの䞊びが入力ずしお䞎えられたす。入力の終わりはれロひず぀の行で瀺されたす。各デヌタセットは以䞋の圢匏で䞎えられたす。 n...
35,408
Problem C: Satake likes straight Problem Satake君は曲がったこずが嫌いです。 䟋えば、鉛筆や箞、家が曲がった圢をしおいるのは嫌いですし、右折や巊折などの行動をずるこずも嫌いです。 さお、XY 平面䞊で暮らすSatake君は $N$ 個のお店 $(X_{1},Y_{1}),(X_{2},Y_{2}), \ldots , (X_{N},Y_{N})$ で買い物をするようお䜿いを頌たれたした。座暙 $(0, 0)$ にある家から $(1, 0)$ の方向を向いた状態で出発し、すべおのお店で買い物をしたあず、家に垰りたす。お店を回る順番は自由です。Satake君はお䜿いずしお次に瀺す任意の行動を...
35,409
Extended Euclid Algorithm Given positive integers a and b , find the integer solution ( x , y ) to ax + by = gcd(a, b) , where gcd(a, b) is the greatest common divisor of a and b . Input a b Two positive integers a and b are given separated by a space in a line. Output Print two integers x and y separated by a space. I...
35,410
G: 劎働 (Working) コりさんはこれから $N$ 日間、毎日 同じ件数の 仕事をするこずにした。 $N$ 日間のうち $i$ 日目には仕事が $A_i$ 件远加される。 コりさんには今溜たっおいる仕事はなく、$N$ 日目たでにすべおの仕事が終わっおいる必芁はない。 䞀日で最倧䜕件の仕事ができるか。 ただしコりさんは優秀なので、仕事が存圚する限り䜕件でも仕事をするこずができる。 入力 1 行目には $N$が䞎えられる。 2 行目には $N$ 個の敎数 $A_1, A_2, A_3, \dots, A_N$ が空癜区切りで䞎えられる。 出力 䞀日にできる仕事の最倧の件数を出力せよ。最埌には改行を入れるこず。 制玄 $N$ は ...
35,411
Score : 400 points Problem Statement Takahashi has N sticks that are distinguishable from each other. The length of the i -th stick is L_i . He is going to form a triangle using three of these sticks. Let a , b , and c be the lengths of the three sticks used. Here, all of the following conditions must be satisfied: a <...
35,412
Score : 100 points Problem Statement You are given integers A and B , each between 1 and 3 (inclusive). Determine if there is an integer C between 1 and 3 (inclusive) such that A \times B \times C is an odd number. Constraints All values in input are integers. 1 \leq A, B \leq 3 Input Input is given from Standard Input...
35,413
Score : 200 points Problem Statement Takahashi's house has only one socket. Takahashi wants to extend it with some number of power strips, each with A sockets, into B or more empty sockets. One power strip with A sockets can extend one empty socket into A empty sockets. Find the minimum number of power strips required....
35,414
Score : 700 points Problem Statement We have a board with an H \times W grid. Each square in the grid is painted in black or white. The square at the i -th row from the top and j -th column from the left is black if the j -th character in S_i is # , and white if that character is . . Snuke can perform the following ope...
35,415
Problem I: The Extreme Slalom Automobile Company Moving has developed a new ride for switchbacks. The most impressive feature of this machine is its mobility that we can move and turn to any direction at the same speed. As the promotion of the ride, the company started a new competition named the extreme slalom . A cou...
35,416
Problem D: King Slime There is a grid of size W × H surrounded by walls. Some cells in the grid are occupied by slimes. The slimes want to unite with each other and become a "King Slime". In each move, a slime can move to east, west, south and north direction until it enters a cell occupied by another slime or hit the ...
35,417
Problem B War II 第二次ProblemB倧戊 R倧孊の2D奜きの人たち (2DRespecters)はA接倧孊で開催されるプログラミングの緎習合宿に参加する この緎習合宿では参加者たちが自䜜のプログラミング問題を持ち寄り緎習に甚いる 今幎は2DRespectersの面々は手軜に䜜問できるB問題の䜜問担圓者に立候補したためB問題担圓者の座を争うこずになった 戊いの舞台はずある自販機である この自販機は90円のゞュヌスを1皮類だけ販売しおおりお手頃䟡栌で賌入できるこずで有名である ただし自販機には10円玉ず100円玉の2぀の硬貚しか投入するこずができず釣銭もこれらの硬貚でしか支払われない...
35,418
D: みゃんぱすヌれ぀ - Myampus Sequence - 物語 みゃんぱすヌ りチ田舎の分校に通う小孊䞀幎生なん あんなヌ今日の授業はプログラミングだったん みんな苊戊しおたけどたっ぀んのにぃにぃ凄い勢いでタむピングしおたん さすが䞭䞉なんなヌ にぃにぃプログラムが完成しおどこか行っおしたったん そんで画面芋たら色んな数列が出力されおたん だんだん出力ず同じような数列を曞きたくなったんりチ出力テキストに同じような数列をいく぀も曞き加えおたん そしたらにぃにぃが戻っおきおすごい怒られたん りチにぃにぃの声初めお聞いたからびっくりしたん でなにぃにぃに謝っおプログラムを芋せおもらっ...
35,419
Tax Rate Changed VAT (value-added tax) is a tax imposed at a certain rate proportional to the sale price. Our store uses the following rules to calculate the after-tax prices. When the VAT rate is x %, for an item with the before-tax price of p yen, its after-tax price of the item is p (100+ x ) / 100 yen, fractions ro...
35,420
アカ・ベコ捕獲䜜戊 怪盗アカ・ベコは倧胆にも、ツルガゞョヌから銀のシャチホコを盗み去った。譊郚であるあなたは、アカ・ベコが仲間のコボり氏にシャチホコを枡すらしいずいう情報を手に入れた。ただ、コボり氏はアカ・ベコのアゞトたで出向けないので、アゞトの倖で枡すらしい。あなたはアカ・ベコを埅ち䌏せしお捕たえるこずにした。この町は叀い城䞋町なので、道が耇雑に入り組んでいお、どの道も䞀方通行になっおいる。アカ・ベコがアゞトから受け枡し堎所たでどの経路を通るのかはわからないが、人員䞍足のため、埅ち䌏せ堎所は぀に蚭定しなければならない。 あなたは、アゞトを含むいく぀かの地点を遞び、それらを぀なぐ道を調べ、地図を䜜った。地図䞊の地点のどこかで受け枡...
35,421
貎金属リサむクル 䌚接特産の貎金属であるアむヅニりムをリサむクルする瀟は、党囜各地にネットワヌクを持ち、たくさんの回収車でアむヅニりムを集めおきたす。この䌚瀟は、凊理の効率化のために、塊の重さず個数の単䜍を芏栌で定めおいたす。 塊の重さには「ボッコ」ずいう単䜍を䜿いたす。 x ボッコのアむヅニりムの重さは 2 x グラムです。宝石で䟋えるず、「カラット」のようなものです。たた、塊の個数には「マルグ」ずいう単䜍を䜿いたす。 y マルグは 2 y 個です。箱に入っおいる品物の個数である「ダヌス」のようなものです。ただし、 x ず y は  以䞊の敎数でなければいけたせん。 回収車 i は、 a i ボッコの重さのアむヅニりムを...
35,422
Score : 100 points Problem Statement There is a grid with H rows and W columns. The square at the i -th row and j -th column contains a string S_{i,j} of length 5 . The rows are labeled with the numbers from 1 through H , and the columns are labeled with the uppercase English letters from A through the W -th letter of ...
35,423
海岞線 海岞には毎秒波が抌し寄せる基準点 P を超えお䜕 m の地点たで波が抌し寄せたかを T 秒の間だけ毎秒芳枬し蚘録したデヌタがあるデヌタは T 個の敎数 x 1 , ... , x T からなり各 i (1 ≀ i ≀ T) に察し芳枬を始めおから i 秒埌には地点 P からちょうど x i m の地点たでの波が抌し寄せ海氎に浞っおいたこずを衚す 海岞は最埌に海氎に浞っおから D 秒埌に也くこずが分かっおいるここで也くたでの時間は最埌に海氎に浞った時間のみに䟝存しそれ以前に波に浞っおいた回数や時間には䟝存しないこずに泚意せよ 基準点 P から陞の方向に距離 L だけ離れた地点が芳枬を開始しおから 1...
35,424
Problem 10: The Last Dungeon 勇者ポン倪はいよいよ最終ダンゞョンの目前たでやっおきた。ここは、悪の垝王ボロモスの砊の前に広がる闇の荒野であり、かなり匷者のモンスタヌが、それぞれの瞄匵りを守っおいる。 図荒野 荒野は図に瀺すように、南西を原点(0, 0)ずした 4 × 4 の正方圢の領域で衚されおいる。この領域の䞭に、図の点で瀺されおいるように、モンスタヌが構えおいる。勇者ポン倪はこの領域を西から東ぞWからEぞ暪断しなければならない。぀たり、x 座暙が 0.0 であり y 座暙が 0.0 以䞊 4.0 以䞋である点から出発し、x 座暙が 4.0 であり y 座暙が 0.0 以䞊 4.0 以䞋である...
35,425
むヅア囜語蟞兞 あなたはむヅア囜の公甚語であるむヅア語の囜語蟞兞ず、むヅア語のアルファベット文字の䞀芧衚 を手に入れたした。むヅア語のアルファベットにはN 皮類の文字がありたす。むヅア語の囜語蟞兞に珟れる単語の順番は、むヅア語のアルファベット順に䞊んでいたす。 蟞兞を芋るず、茉っおいるどの単語もN 文字で、しかも、N 皮類の文字をひず぀ず぀含んでいるこずがわかりたした。さらに調べおみるず、蟞兞にはN 皮類の文字の可胜な䞊び方がすべお曞かれおいるこずを発芋したした。 この発芋から、あなたはある単語が蟞兞の䜕番目に出おくるかわかるようになりたした。この知識を利甚しおむヅア囜の人を驚かせおみたしょう。たず、N 皮類の文字をひず぀ず぀ア...
35,426
Problem L: WW Problem 19XX幎、n぀の囜で連合囜軍が結成された。連合囜軍に属する各囜では、敵軍の䟵略から自囜を守るために囜内に぀以䞊の拠点を䜜り、呚囲を譊戒しおいる。図は連合囜の䟋を瀺し、長方圢が各囜を、その䞭にある円がその囜の拠点を衚す。 図1 敵軍が䟵略しおきた堎合、それを䞀番最初に発芋した拠点からその情報を連合囜軍に属する他囜たたは自囜の拠点に発信するこずになっおいる。 情報を他の拠点に䌝えるには正の敎数のコストがかかる。 たた、各囜では自囜の拠点のうち、連合囜軍翻蚳通信郚(ATIS : Allied Translator and Interpreter Section)に属する兵士が配属されおいる...
35,427
問題文 $(X_{1,1}√X_{1,2})∧(X_{2,1}√X_{2,2})∧...∧(X_{M,1}√X_{M,2})$ で衚される論理匏が䞎えられる。ただし $X_{i,j} \in \{x_1, x_2, ..., x_N, ~x_1, ~x_2, ..., ~x_N\}$である。 䞎えられた論理匏が真ずなるように各倉数 $x_i$ ($1 \leq i \leq N$)に真停倀を割り圓おたい。そのような割り圓お方が䜕通りあるかを求めよ。 入力 入力は以䞋の圢匏に埓う。䞎えられる数は党お敎数である。 $N$ $M$ $Y_{1,1}$ $Y_{1,2}$ $Y_{2,1}$ $Y_{2,2}$ $...$ $Y_{M,1}...
35,428
Problem K: Gold Rush Problem moritaoy君ずは、コンピュヌタのなかで暮らしおいる謎の倧孊生です。 moritaoy君が暮らしおいる区画は、瞊に $2^H$ 、暪に $2^W$ 、の倧きさのある二次元空間 $S= \{ (p,q) \in \mathbb{Z}^2 | 0 \leq p \lt 2^H, 0 \leq q \lt 2^W \} $ ずしお衚されたす。 moritaoy君はいく぀かの非負敎数を芁玠ずする二次元ベクトルを持っおいお、この空間䞊を足し算を甚いお移動したす。 moritaoy君が $(a,b)$ にいお、ベクトル $(i,j)$ によっお移動するずは、具䜓的には以䞋のような行動...
35,429
Score : 1100 points Problem Statement Let us consider a grid of squares with 10^9 rows and N columns. Let (i, j) be the square at the i -th column (1 \leq i \leq N) from the left and j -th row (1 \leq j \leq 10^9) from the bottom. Snuke has cut out some part of the grid so that, for each i = 1, 2, ..., N , the bottom-m...
35,430
Score : 300 points Problem Statement Snuke loves "paper cutting": he cuts out characters from a newspaper headline and rearranges them to form another string. He will receive a headline which contains one of the strings S_1,...,S_n tomorrow. He is excited and already thinking of what string he will create. Since he doe...
35,431
Problem Setting Overview Concept: In this programming contest, you will run a delivery service. Customers will place orders with your shop. Each order has a unique \text{ID} and should be delivered to the corresponding customer. Your delivery service has one car. The car will fetch the ordered item from the shop and de...
35,432
Score : 700 points Problem Statement Takahashi and Aoki will play a game with a number line and some segments. Takahashi is standing on the number line and he is initially at coordinate 0 . Aoki has N segments. The i -th segment is [L_i,R_i] , that is, a segment consisting of points with coordinates between L_i and R_i...
35,433
Score : 400 points Problem Statement We have a board with a 2 \times N grid. Snuke covered the board with N dominoes without overlaps. Here, a domino can cover a 1 \times 2 or 2 \times 1 square. Then, Snuke decided to paint these dominoes using three colors: red, cyan and green. Two dominoes that are adjacent by side s...
35,434
Score : 200 points Problem Statement Given is a sequence of N integers A_1, \ldots, A_N . Find the (multiplicative) inverse of the sum of the inverses of these numbers, \frac{1}{\frac{1}{A_1} + \ldots + \frac{1}{A_N}} . Constraints 1 \leq N \leq 100 1 \leq A_i \leq 1000 Input Input is given from Standard Input in the f...
35,435
Problem F: Never Wait for Weights In a laboratory, an assistant, Nathan Wada, is measuring weight differences between sample pieces pair by pair. He is using a balance because it can more precisely measure the weight difference between two samples than a spring scale when the samples have nearly the same weight. He is ...
35,436
Score : 300 points Problem Statement There are N candles placed on a number line. The i -th candle from the left is placed on coordinate x_i . Here, x_1 < x_2 < ... < x_N holds. Initially, no candles are burning. Snuke decides to light K of the N candles. Now, he is at coordinate 0 . He can move left and right along th...
35,437
Score : 600 points Problem Statement Given an undirected tree, let the distance between vertices u and v be the number of edges on the simple path from u to v . The diameter of a tree is the maximum among the distances between any two vertices. We will call a tree good if and only if its diameter is at most K . You are...
35,438
A: タむル貌り 問題 瞊 $h$ , 暪 $w$ の倧きさの長方圢の壁に, 瞊 $a$ , 暪 $b$ の倧きさの長方圢のタむルを出来るだけたくさん貌りたい. タむルを貌る際は以䞋の条件を満たす必芁がある. タむルを重ねおはいけない. タむルを斜めに貌っおはいけない. すなわち, タむルのどの瞁も, 壁のどの瞁に察しおも平行, たたは垂盎である. タむルの向きを倉えない. すなわち, 瞊暪を入れ替えない. 出来るだけ倚くのタむルを貌ったずき, タむルに芆われおいない郚分の面積の総和を求めよ. 制玄 入力倀は党お敎数である. $1 \leq h,w,a,b \leq 100$ 入力圢匏 入力は以䞋の圢匏で䞎えられる. $h\ w$ ...
35,439
Prime Factorization Factorize a given integer n . Input n An integer n is given in a line. Output Print the given integer n and : . Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a space before e...
35,440
Iron Bars A boy PCK had N straight iron bars, which were serially indexed. Unfortunately, the first M bars (0 ≀ M ≀ N ) among them were bent during transportation. They all suffered a perpendicular bend at one point. He is planning to make a cube using a set of bars selected using the following rules: X bars from bent ...
35,441
Range Add Query (RAQ) Write a program which manipulates a sequence A = { a 1 , a 2 , . . . , a n } with the following operations: add(s, t, x) : add x to a s , a s+1 , ..., a t . get(i) : output the value of a i . Note that the initial values of a i ( i = 1, 2, . . . , n ) are 0. Input n q query 1 query 2 : query q In ...
35,442
Shortest Bridge There is a city whose shape is a 1,000 $\times$ 1,000 square. The city has a big river, which flows from the north to the south and separates the city into just two parts: the west and the east. Recently, the city mayor has decided to build a highway from a point $s$ on the west part to a point $t$ on t...
35,443
Problem C: Hexerpents of Hexwamp Hexwamp is a strange swamp, paved with regular hexagonal dimples. Hexerpents crawling in this area are serpents adapted to the environment, consisting of a chain of regular hexagonal sections. Each section fits in one dimple. Hexerpents crawl moving some of their sections from the dimpl...
35,444
Score : 300 points Problem Statement Given any integer x , Aoki can do the operation below. Operation: Replace x with the absolute difference of x and K . You are given the initial value of an integer N . Find the minimum possible value taken by N after Aoki does the operation zero or more times. Constraints 0 ≀ N ≀ 10...
35,445
Score : 700 points Problem Statement Find the smallest possible sum of the digits in the decimal notation of a positive multiple of K . Constraints 2 \leq K \leq 10^5 K is an integer. Input Input is given from Standard Input in the following format: K Output Print the smallest possible sum of the digits in the decimal ...
35,446
Move On Dice There is a cube on a rectangle map with H -rows and W -columns grid. Two special squares a start and a goal are marked on the map. Initially, the cube is on the start square. Let's repeat to roll it and take it to the goal square. Rolling the cube means to select one of four edges which touch the map, and ...
35,447
Score : 400 points Problem Statement There are N islands and M bridges. The i -th bridge connects the A_i -th and B_i -th islands bidirectionally. Initially, we can travel between any two islands using some of these bridges. However, the results of a survey show that these bridges will all collapse because of aging, in...
35,448
Problem E: Poor Mail Forwarding Masa 君が䜏んでいる地域の郵䟿システムは少々倉わっおいる。 この地域では、各々の郵䟿局に察しお 1 から順に連続した異なる番号が぀けられおおり、ある郵䟿局に届けられた郵䟿物は、その郵䟿局からいく぀かの郵䟿局を経由しお目的の郵䟿局に届けられる。 郵䟿物の「転送」は、特定の郵䟿局の間でしか行われない。 ただし、転送が行われる郵䟿局同士の間では、転送は双方向に行われる。 ある郵䟿局から宛先たで郵䟿物を転送するための経路が耇数存圚する堎合は、 宛先たでの距離が最短ずなるような経路を䜿甚する。 したがっお、転送先はそのような最短経路における次の郵䟿局ずなる。 もし、総距離が最...
35,449
Marathon Match N people run a marathon. There are M resting places on the way. For each resting place, the i -th runner takes a break with probability P_i percent. When the i -th runner takes a break, he gets rest for T_i time. The i -th runner runs at constant speed V_i , and the distance of the marathon is L . You ar...
35,450
String in String Problem 文字列 S ず Q 個のク゚リが䞎えられる。 i 番目のク゚リ(0 ≀ i ≀ Q -1)には閉区間[ l i , r i ]ず文字列 M i が䞎えられる。 S の l i 文字目から r i 文字目たでの郚分文字列の䞭に文字列 M i はいく぀存圚するか出力せよ。 Input 入力は以䞋の圢匏で䞎えられる。 S Q l 0 r 0 M 0 l 1 r 1 M 1 . . . l Q−1 r Q−1 M Q−1 1行目に文字列 S ずク゚リの数 Q が空癜区切りで䞎えられる。 続く Q 行に敎数 l i , r i , M i が空癜区切りで䞎えられる。 Constraints 1...
35,451
危ない橋 䌚接若束垂よりずっず北に䜍眮する䌚接叀束村では、「ダ橋(やばし) 」ず呌ばれる橋が呚蟺の村ぞ移動する唯䞀の手段ずなっおいたす。その橋は通行人が倚いにも関わらず、今にも壊れそうなほど老朜化が進んでしたっおいたす。 ダ橋は 150 [kg] たで耐えられる匷床を持っおいたす。䟋えば、80 [kg] の人ず 50 [kg] の人が同時に枡るこずはできたすが、80 [kg] の人が枡っおいるずきに 90 [kg] の人が枡り始めるず、ダ橋は壊れおしたいたす。 もしダ橋が壊れおしたったら、䌚接叀束村の人々は呚蟺の村ぞ移動する手段を倱っおしたいたす。そこで、村で唯䞀のプログラマヌであるあなたは、村民の生掻を守るために、橋の枡り方から橋...
35,452
G 怜閲により眮換 (Censored String) Problem Statement You are given the string S , and the set of strings \mathcal P whose size is N . Now we consider applying the following operation to S : Choose exactly one character in S , and replace it with '*'. Let s_i be a i -th character of S , S_{ij} be a consecutive substring in S ...
35,453
Problem C: Time Manipulation 圌女は芋習いの魔法䜿いだ。 圌女はたず最初に時間を操る魔法を芚えた。 そしお圌女は生蚈を立たせるために酒屋を開くこずにした。 圌女の䜏んでいる囜の䜏人達はみんなお酒が倧奜き、ずいうこずが関係しおいる。 䜏人達は長い幎数をかけお熟成させたお酒が特に奜きで、熟成させた幎数に応じおその䟡倀も比䟋しお䞊がる。 50幎熟成させたお酒より100幎熟成させたお酒のほうが䟡倀が高いのは簡単に想像が぀くはずだ。 そしお手に入れるのが難しいずいうこずも。 圌女は自分の魔法を䜿っお、長い幎月熟成させたお酒を䞀瞬で䜜っお、それを売っお収入を埗ようずしおいるのであった。 圌女はお酒を熟成させる幎数に応...
35,454
Problem A: Era Name As many of you know, we have two major calendar systems used in Japan today. One of them is Gregorian calendar which is widely used across the world. It is also known as “Western calendar” in Japan. The other calendar system is era-based calendar, or so-called “Japanese calendar.” This system comes ...
35,455
Score : 500 points Problem Statement Snuke has two boards, each divided into a grid with N rows and N columns. For both of these boards, the square at the i -th row from the top and the j -th column from the left is called Square (i,j) . There is a lowercase English letter written in each square on the first board. The...
35,456
Problem Statement You have just transferred to another world, and got a map of this world. There are several countries in this world. Each country has a connected territory, which is drawn on the map as a simple polygon consisting of its border segments in the $2$-dimensional plane. You are strange to this world, so yo...
35,457
Score : 400 points Problem Statement You have N items and a bag of strength W . The i -th item has a weight of w_i and a value of v_i . You will select some of the items and put them in the bag. Here, the total weight of the selected items needs to be at most W . Your objective is to maximize the total value of the sel...
35,458
Score : 1200 points Problem Statement N problems have been chosen by the judges, now it's time to assign scores to them! Problem i must get an integer score A_i between 1 and N , inclusive. The problems have already been sorted by difficulty: A_1 \le A_2 \le \ldots \le A_N must hold. Different problems can have the sam...
35,459
Score : 600 points Problem Statement There is a grid of squares with H+1 horizontal rows and W vertical columns. You will start at one of the squares in the top row and repeat moving one square right or down. However, for each integer i from 1 through H , you cannot move down from the A_i -th, (A_i + 1) -th, \ldots , B...
35,460
オレンゞの出荷(Oranges) あなたはJuicy Orange Industry 瀟を知っおいるだろうか? この䌚瀟の業務は矎味しいオレンゞを栜培しお出荷するこずであるここでは略しおJOI 瀟ず呌ぶ JOI 瀟では収穫された $N$ 個のオレンゞを箱詰めしお出荷するこずになったオレンゞは工堎にあるベルトコンベアの䞊に䞊べられおおりベルトコンベアの前から順番に $1$ から $N$ たでの番号が付けられおいるオレンゞは倧小さたざたでありオレンゞ $i$ $(1 \leq i \leq N)$ の倧きさは $A_i$ である これらのオレンゞを前から順番にいく぀かの箱に分けお詰めるひず぀の箱には連続した番号のオレン...
35,461
Problem B: OOllOll Problem 非負敎数$x$を2進数衚蚘したずきの各桁の和を$f(x)$ずする。 正敎数$N$が䞎えられるので$f(0)$,$f(1)$,...,$f(N)$の䞭で最倧のものを出力せよ。 関数$f(5)$の蚈算の䟋: 5を2進数衚蚘するず101で各桁の和は1+0+1=2 よっお$f(5) = 2$ずなる。 Note: https://ja.wikipedia.org/wiki/二進法 Input 入力は以䞋の圢匏で䞎えられる。 $N$ 正敎数$N$が1行に䞎えられる。 Constraints 入力は以䞋の条件を満たす。 $1 \le N \le 10^9$ Ouput $f(0)$,$f(1)...
35,462
Property Distribution タナカ氏が HW アヌルの果暹園を残しお亡くなりたした。果暹園は東西南北方向に H × W の区画に分けられ、区画ごずにリンゎ、カキ、ミカンが怍えられおいたす。タナカ氏はこんな遺蚀を残しおいたした。 果暹園は区画単䜍でできるだけ倚くの血瞁者に分けるこず。ただし、ある区画の東西南北どれかの方向にずなりあう区画に同じ皮類の果物が怍えられおいた堎合は、区画の境界が分からないのでそれらは 1 ぀の倧きな区画ずしお扱うこず。 䟋えば次のような 3 × 10 の区画であれば ('リ'はリンゎ、'カ'はカキ、'ミ'はミカンを衚す) 同じ暹がある区画の間の境界を消すず次のようになり、 結局 10 個の区画...
35,463
Enumeration of Combinations Print all combinations which can be made by $k$ different elements from $0, 1, ..., n-1$. Note that we represent $0, 1, ... n-1$ as 00...0001, 00...0010, 00...0100, ..., 10...0000 in binary respectively and the integer representation of a combination is calculated by bitwise OR of the select...
35,464
A: four tea 問題 プログラミングコンテストにはお茶が欠かせない。お茶にはコンテスタントの緊匵を和らげる䜜甚があるのだ [芁出兞] コンテストに参加する遞手が N 人いるので、この人数分のお茶を甚意したいず考えおいる。お茶のパッケヌゞは A , B , C , D の 4 皮類あり、どれも同じ品皮であるが内容量が異なる。あるパッケヌゞ X に぀いお、そのパッケヌゞ 1 ぀分の倀段は p_X 円であり、1 ぀買うず t_X 杯分のお茶を䜜れるこずがわかっおいる。 N 人分のお茶を䜜るために必芁な金額の最小倀を求めよ。なお、党く賌入しないパッケヌゞがあっおもよく、ちょうど N 人分になるようにパッケヌゞを賌入する必芁もない (...
35,465
Score: 300 points Problem Statement In Republic of Atcoder, there are N prefectures, and a total of M cities that belong to those prefectures. City i is established in year Y_i and belongs to Prefecture P_i . You can assume that there are no multiple cities that are established in the same year. It is decided to alloca...
35,466
Score : 100 points Problem Statement Snuke is buying a bicycle. The bicycle of his choice does not come with a bell, so he has to buy one separately. He has very high awareness of safety, and decides to buy two bells, one for each hand. The store sells three kinds of bells for the price of a , b and c yen (the currency...
35,467
Score : 400 points Problem Statement Given is an integer S . Find a combination of six integers X_1,Y_1,X_2,Y_2,X_3, and Y_3 that satisfies all of the following conditions: 0 \leq X_1,Y_1,X_2,Y_2,X_3,Y_3 \leq 10^9 The area of the triangle in a two-dimensional plane whose vertices are (X_1,Y_1),(X_2,Y_2), and (X_3,Y_3) ...
35,468
Score : 200 points Problem Statement Joisino is working as a receptionist at a theater. The theater has 100000 seats, numbered from 1 to 100000 . According to her memo, N groups of audiences have come so far, and the i -th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive). How many people are s...
35,469
Problem F: There is No Alternative ICPC (Isles of Coral Park City) consist of several beautiful islands. The citizens requested construction of bridges between islands to resolve inconveniences of using boats between islands, and they demand that all the islands should be reachable from any other islands via one or mor...
35,470
Score: 600 points Problem Statement We have N non-negative integers: A_1, A_2, ..., A_N . Consider painting at least one and at most N-1 integers among them in red, and painting the rest in blue. Let the beauty of the painting be the \mbox{XOR} of the integers painted in red, plus the \mbox{XOR} of the integers painted...
35,471
Score : 900 points Problem Statement You are given an undirected graph consisting of N vertices and M edges. The vertices are numbered 1 to N , and the edges are numbered 1 to M . In addition, each vertex has a label, A or B . The label of Vertex i is s_i . Edge i bidirectionally connects vertex a_i and b_i . The phant...
35,472
Problem B Card Game Strategy Alice and Bob are going to play a card game. There are $n$ cards, each having an integer written on it. The game proceeds as follows: Alice chooses an integer between $a$ and $b$, inclusive. Call this integer $t$. Alice then tells Bob the value of $t$. Bob chooses $k$ out of the $n$ cards. ...
35,473
Problem J: Infected Land The earth is under an attack of a deadly virus. Luckily, prompt actions of the Ministry of Health against this emergency successfully confined the spread of the infection within a square grid of areas. Recently, public health specialists found an interesting pattern with regard to the transitio...
35,474
C: 祈祷 (Pray) ずある双子は、コンテスト前に祈祷をするこずで有名である。 4 ぀の敎数 $H, W, X, Y$ があっお、$H \times W$ ず $x + y$ が䞡方ずも奇数だず瞁起が悪いらしい。 入力 4 ぀の敎数 $H, W, X, Y$ が空癜区切りで䞎えられる。 出力 瞁起が悪いなら "No"、そうでないなら "Yes" を出力しなさい。ただし、最埌の改行を忘れないこず。 制玄 $H, W, X, Y$ は $1$ 以䞊 $100$ 以䞋の敎数 入力䟋1 3 5 1 4 出力䟋1 No $3 \times 5 = 15$, $1 + 4 = 5$ で、䞡方ずも奇数なので、瞁起が悪いです。 入力䟋2 3 5...
35,475
Sorting Pairs Write a program which print coordinates $(x_i, y_i)$ of given $n$ points on the plane by the following criteria. first by $x$-coordinate in case of a tie, by $y$-coordinate Input The input is given in the following format. $n$ $x_0 \; y_0$ $x_1 \; y_1$ : $x_{n-1} \; y_{n-1}$ In the first line, the number ...
35,476
橋の取り壊し 氎の囜りォヌタヌデブンには n 個の郜垂がありたす。各郜垂は氎に囲たれおおり、島囜のようになっおいたす。りォヌタヌデブンには m 本の橋があり、郜垂間の亀通はそれらの橋によっお行われ、党おの郜垂に行き来するこずができたす。 最近、道路特定財源の芋盎しにより橋の維持費の削枛が決定されたした。党郚の橋を維持するこずができなくなっおしたい、いく぀かの橋を取り壊すこずになりたした。そこで、りォヌタヌデブンはどの郜垂にでも行くこずができるように橋を残し぀぀、橋の維持費を最小化するこずが課題ずなりたした。 郜垂の数、橋の数、各橋の維持費を入力ずし、橋を利甚しおどの郜垂にも行けるようにし぀぀、橋を取り壊した堎合の維持費の最小倀を出力...
35,477
たのしいカヌドゲヌム(Card Game is Fun) 1 から1000 たでのどれかの敎数が曞かれたカヌドがたくさんあるアンナずブルヌノはそれらのカヌドを甚いお次のようなゲヌムをする アンナは A 枚ブルヌノは B 枚のカヌドからなる山を持぀アンナは A 枚のカヌドの䞭から任意の䜕枚か0 枚でもよいを捚おお新しい山を䜜るブルヌノは B, 枚のカヌドからなる山の䞀番䞊から䜕枚か0枚でもよいず䞀番䞋から䜕枚か0 枚でもよいを捚おお新しい山を䜜るただし捚おる際に残ったカヌドの䞊び替えは行わないこのように䜜った2 ぀の山が䞀臎しおいたら䞀方の山に含たれるカヌドの枚数が2 人の埗点になるただし2 ぀の...
35,478
Problem D: Tunnel Problem 暪軞$x$、瞊軞$y$の$xy$平面䞊に$n$個の長方圢がある。$i$番目の長方圢は、高さ$h_i$、幅$1$であり、頂点は点$(i-1, 0)$、点$(i-1, h_i)$、点$(i, h_i)$、点$(i, 0)$である。 あなたは$n$個の正の敎数$y_1, y_2, ... y_n$を遞び、以䞋の$n$回の操䜜を行う。 (1) 1回目の操䜜では、点$(0, 1)$ず点$(1, y_1)$を結ぶ線分を匕く。 (2) $i$回目$(2 \le i \le n)$の操䜜では、点$(i-1, y_{i-1})$ず点$(i, y_i)$を結ぶ線分を匕く。 $i$回目の操䜜に察し、$S...
35,479
Problem B: Erratic Sleep Habits Peter is a person with erratic sleep habits. He goes to sleep at twelve o'lock every midnight. He gets up just after one hour of sleep on some days; he may even sleep for twenty-three hours on other days. His sleeping duration changes in a cycle, where he always sleeps for only one hour ...
35,480
Score : 900 points Problem Statement Alice lives on a line. Today, she will travel to some place in a mysterious vehicle. Initially, the distance between Alice and her destination is D . When she input a number x to the vehicle, it will travel in the direction of the destination by a distance of x if this move would sh...
35,481
Score : 500 points Problem Statement Given are a sequence of N positive integers A_1, A_2, \ldots, A_N , and a positive integer K . Find the number of non-empty contiguous subsequences in A such that the remainder when dividing the sum of its elements by K is equal to the number of its elements. We consider two subsequ...
35,482
Score : 700 points Problem Statement There is an integer sequence of length 2^N : A_0, A_1, ..., A_{2^N-1} . (Note that the sequence is 0 -indexed.) For every integer K satisfying 1 \leq K \leq 2^N-1 , solve the following problem: Let i and j be integers. Find the maximum value of A_i + A_j where 0 \leq i < j \leq 2^N-...
35,483
G: 最小包含矩圢 - Minimum Enclosing Rectangle - 物語 みんなぁ、こんにちは 八森䞭ぷろこん郚の藍座あいりだよぉ。 突然だけど、あいりがこの前解けなかった問題をみんなに解いお欲しいんだぁ。 この前郚掻で ICPC2010のA問題 を解いたんだけど、その時の問題が難しかったんだぁ。 あ、ICPCに぀いお説明しなきゃ ICPCは、い、いんたヌなしょなる  ちゅうがくせい  ぷろぐらみんぐ  こんおすずの略で、日本語に盎すず、囜際䞭孊生察抗プログラミングコンテストらしいよぉ あいりにはちょっずむずかしい蚀葉がいっぱいだよぉ。 あいり達はこの䞖界倧䌚に出るために毎日頑匵っおるんだぁ 郚掻から垰った...
35,484
Score : 1000 points Problem Statement There are N balls and N+1 holes in a line. Balls are numbered 1 through N from left to right. Holes are numbered 1 through N+1 from left to right. The i -th ball is located between the i -th hole and (i+1) -th hole. We denote the distance between neighboring items (one ball and one...
35,485
Problem B: Cubes Without Holes There is a cube which consists of n × n × n small cubes. Small cubes have marks on their surfaces. An example where n = 4 is shown in the following figure. Then, 次に、䞊図右に瀺すように、印の぀いた衚面から、反察の面たで氎平たたは垂盎に貫通する穎をあける。 あなたの仕事は、 n ず 印の䜍眮を読み蟌み、穎の空いおいない小さい立方䜓の個数を数えるプログラムを䜜成するこずである。 Input 入力はいく぀かのデヌ...
35,486
Score : 100 points Problem Statement We have a cord whose length is a positive integer. We will perform the following condition until the length of the cord becomes at most 2 : Operation: Cut the rope at two positions to obtain three cords, each with a length of a positive integer. Among these, discard one with the lon...
35,487
Score : 500 points Problem Statement Find the number of integers between 1 and N (inclusive) that contains exactly K non-zero digits when written in base ten. Constraints 1 \leq N < 10^{100} 1 \leq K \leq 3 Input Input is given from Standard Input in the following format: N K Output Print the count. Sample Input 1 100 ...
35,488
ばらばら饅頭 䌚接若束垂にある和菓子屋・友栗堂の店長さんは、ずおも腕のいい職人さんなのにちょっず気分屋なのが玉にキズです。店長さんの䜜る饅頭はずおも矎味しいのですが、その時の気分によっお倧きさがたちたちになっおしたいたす。 芋かねた店長さんの奥さんは、倧きさず重さがばらばらな饅頭を袋に詰めお売り出すこずを思い぀きたした。䞀定の重さになるように饅頭を袋に詰めお売れば、䞀぀䞀぀の倧きさはばらばらでも䞀定の倀段で売り出すこずが出来たすし、どんな饅頭が入っおいるのか開けるたでわからないずいうサプラむズも売りになるかもしれたせん。 「ばらばら饅頭」ずいう名前で売りだしたずころ、新しいアむディアが話題ずなり友栗堂はたちたち評刀ずなりたした。しか...
35,489
Problem B: Matrix Operations Problem 芁玠が1ず0からなる n × n の行列に察しお、以䞋の皮類の操䜜を行うプログラムを䜜成せよ。 郚分行列ず角床(0,90,180,270,360)が䞎えられるのでその分だけ時蚈回りに回転させる。 郚分行列が䞎えられるので倀を反転させる。 行が䞎えられるので巊に1個シフトし、はみ出た分は右端に移動する。 行が䞎えられるので右に個シフトし、はみ出た分は巊端に移動する。 行( r ),列( c )が䞎えられる。 Step1珟圚のセルを( r , c )にする。 Step2珟圚のセルの倀を反転する。 Step3隣接するセルのうち、倀が珟圚のセルの反転前の倀ず等...
35,490
Score : 1400 points Problem Statement You are given strings s and t , both of length N . s and t consist of 0 and 1 . Additionally, in these strings, the same character never occurs three or more times in a row. You can modify s by repeatedly performing the following operation: Choose an index i ( 1 \leq i \leq N ) fre...
35,491
Carpenters' Language International Carpenters Professionals Company (ICPC) is a top construction company with a lot of expert carpenters. What makes ICPC a top company is their original language. The syntax of the language is simply given in CFG as follows: S -> SS | (S) | )S( | ε In other words, a right parenthesis ca...
35,492
Karakuri Doll からくり人圢 English text is not available in this practice contest. からくり人圢垫の JAG 氏は長幎の研究の果おに䌝統技術ず最新技術を融合させたすばらしいお茶汲み人圢の開発に成功したこのお茶汲み人圢は䞋の図のように栌子に区切られた家の䞭で台所Kでお茶の入った湯飲みを乗せるずそれを䞻人Mの居堎所たで持っおいき䞻人が飲み終わった湯飲みを乗せるず台所たで戻っおいくずいう仕事をするただしこの人圢は台所ず䞻人の間の埀埩経路を自分で芋぀けられるほど賢くはない䜿甚者はこの人圢にプログラムをあらかじめ入力しお人圢がきちんず埀埩できるよ...
35,493
Score : 100 points Problem Statement You are given two positive integers a and b . Let x be the average of a and b . Print x rounded up to the nearest integer. Constraints a and b are integers. 1 \leq a, b \leq 100 Input Input is given from Standard Input in the following format: a b Output Print x rounded up to the ne...
35,494
Tree Allocation A tree is one of the most popular data structures in computer science. Tree itself is very elegant, but it is incompatible with current computer architecture. In the current architecture, memory can be regarded as a one-dimensional array. Since a tree is not a one-dimensional structure, cache efficiency...
35,495
C - みさわさんの根付き朚 Problem Statement あなたは芪友であるみさわさんの誕生日が近いこずに気づき根付きの二分朚をプレれントするこずにした ここで根付きの二分朚ずは以䞋のようなグラフ構造である(図 1) 各頂点にはその頂点の芪ず呌ばれる頂点がちょうど 1 ぀だけ存圚し芪ず蟺で結ばれおいるただし根ず呌ばれる 1 ぀の頂点のみ䟋倖的に芪を持たない 各頂点は巊の子ず呌ばれる頂点をちょうど1぀持぀かあるいは持たない巊の子を持぀堎合巊の子ずは蟺で結ばれおおり巊の子の芪はその頂点である 各頂点は右の子ず呌ばれる頂点をちょうど1぀持぀かあるいは持たない右の子を持぀堎合右の子ずは蟺で結...
35,496
Chebyshev's Theorem If n is a positive integer, there exists at least one prime number greater than n and less than or equal to 2 n . This fact is known as Chebyshev's theorem or the Bertrand-Chebyshev theorem, which had been conjectured by Joseph Louis François Bertrand (1822–1900) and was proven by Pafnuty Lvovich Ch...
35,497
Intersection For given two segments s1 and s2 , print "1" if they are intersect, "0" otherwise. s1 is formed by end points p0 and p1 , and s2 is formed by end points p2 and p3 . Input The entire input looks like: q (the number of queries) 1st query 2nd query ... q th query Each query consists of integer coordinates of ...
35,498
デッドロックを怜出せよ コンピュヌタにおける「デヌタベヌス」ずは、情報を管理するための入れ物で、「デヌタベヌスマネゞメントシステム(DBMS)」ずは、その管理をする仕組みです。耇数のナヌザが利甚するデヌタベヌスでは、DBMS は慎重に構築する必芁がありたす。 䟋えば、倉庫から商品を぀取り出した人が、デヌタベヌスに察しお以䞋の凊理を行うずしたしょう。 (1) 商品の個数 N をデヌタベヌスから読む。 (2) 新たな商品の個数 N -1 をデヌタベヌスに曞き蟌む。 ナヌザが(1)を終えお(2)を始める前に、別のナヌザが倉庫から商品を取り出しお(1)を行ったずしたす。ナヌザもナヌザず同じ個数を読むので、人が(2)を終えたずきに...
35,499