url
stringlengths
49
92
description
stringlengths
22
4.78k
cases
listlengths
0
6
https://atcoder.jp/contests/abc365/tasks/abc365_b
Problem Statement You are given an integer sequence A=(A_1,\ldots,A_N) of length N . Here, A_1, A_2, \ldots, A_N are all distinct. Which element in A is the second largest?
[ { "input": "4\n8 2 5 1\n", "output": "3\n" }, { "input": "8\n1 2 3 4 5 10 9 11\n", "output": "6\n" } ]
https://atcoder.jp/contests/abc365/tasks/abc365_c
Problem Statement There are N people participating in an event, and the transportation cost for the i -th person is A_i yen. Takahashi, the organizer of the event, decided to set a maximum limit x for the transportation subsidy. The subsidy for person i will be \min(x, A_i) yen. Here, x must be a non-negative integer. ...
[ { "input": "4 8\n1 3 2 4\n", "output": "2\n" }, { "input": "3 20\n5 3 2\n", "output": "infinite\n" }, { "input": "10 23\n2 5 6 5 2 1 7 9 7 2\n", "output": "2\n" } ]
https://atcoder.jp/contests/abc365/tasks/abc365_d
Problem Statement Takahashi and Aoki played rock-paper-scissors N times. [Note: In this game, Rock beats Scissors, Scissors beats Paper, and Paper beats Rock.] Aoki's moves are represented by a string S of length N consisting of the characters R , P , and S . The i -th character of S indicates Aoki's move in the i -th...
[ { "input": "6\nPRSSRS\n", "output": "5\n" }, { "input": "10\nSSSSSSSSSS\n", "output": "5\n" }, { "input": "24\nSPRPSRRRRRPPRPRPSSRSPRSS\n", "output": "18\n" } ]
https://atcoder.jp/contests/abc365/tasks/abc365_e
Problem Statement You are given an integer sequence A=(A_1,\ldots,A_N) of length N . Find the value of the following expression: \displaystyle \sum_{i=1}^{N-1}\sum_{j=i+1}^N (A_i \oplus A_{i+1}\oplus \ldots \oplus A_j) . Notes on bitwise XOR The bitwise XOR of non-negative integers A and B , denoted as A \oplus B , is ...
[ { "input": "3\n1 3 2\n", "output": "3\n" }, { "input": "7\n2 5 6 5 2 1 7\n", "output": "83\n" } ]
https://atcoder.jp/contests/abc365/tasks/abc365_f
Problem Statement There are infinitely many cells on a plane. For every pair of integers (x,y) , there is a corresponding cell, which we will call cell (x,y) . Each cell is either an empty cell or a wall cell. You are given two sequences of positive integers of length N : L=(L _ 1,L _ 2,\dotsc,L _ N) and U=(U _ 1,U _ ...
[ { "input": "7\n1 5\n3 3\n1 3\n1 1\n1 4\n2 4\n3 5\n3\n1 4 6 3\n1 4 1 1\n7 5 1 5\n", "output": "10\n3\n14\n" }, { "input": "12\n1 1000000000\n1000000000 1000000000\n1 1000000000\n1 1\n1 1000000000\n1000000000 1000000000\n1 1000000000\n1 1\n1 1000000000\n1000000000 1000000000\n1 1000000000\n1 1\n1\n1 1...
https://atcoder.jp/contests/abc365/tasks/abc365_g
Problem Statement N people work at the AtCoder office. The office keeps records of entries and exits, and there have been M entries and exits since the records began. The i -th (1\leq i\leq M) record is represented by a pair of integers (T_i, P_i) , indicating that at time T_i , the P_i -th person either entered the of...
[ { "input": "3 8\n10 1\n20 2\n30 1\n40 3\n60 3\n70 1\n80 2\n90 1\n3\n1 2\n1 3\n2 3\n", "output": "20\n0\n20\n" }, { "input": "10 20\n10257 9\n10490 4\n19335 1\n25893 5\n32538 9\n33433 3\n38522 9\n40629 9\n42896 5\n52106 1\n53024 3\n55610 5\n56721 9\n58286 9\n63128 3\n70513 3\n70977 4\n74936 5\n79883 ...
https://atcoder.jp/contests/codequeen2024-final-N9tn8QqD/tasks/codequeen2024_final_a
問題文 AtCoder Land は、 10 時ちょうど、 15 時ちょうど、 17 時ちょうどの 3 つのタイミングでしか入場できません。 高橋君は X 時ちょうどに AtCoder Land に到着しました。最短で何時ちょうどに入園できますか? 但し、高橋君の到着と同じタイミングに AtCoder Land に入場できる場合も、高橋君は AtCoder Land に入場できるものとします。
[ { "input": "14\n", "output": "15\n" }, { "input": "17\n", "output": "17\n" }, { "input": "6\n", "output": "10\n" } ]
https://atcoder.jp/contests/codequeen2024-final-N9tn8QqD/tasks/codequeen2024_final_b
問題文 AtCoder Land では時報がモールス信号で行なわれます。高橋君はこのモールス信号を解読したいです。 N 個の文字列 S_1, S_2, \ldots, S_N が与えられます。 S_i (1 \leq i \leq N) は . と - からなる文字列で、 0 以上 9 以下のある数字に対応するモールス符号です。 N 個の文字列を復号し、順に連結して 1 つの文字列として出力してください。 数字とモールス符号の対応は以下の通りです。 0 ----- 1 .---- 2 ..--- 3 ...-- 4 ....- 5 ..... 6 -.... 7 --... 8 ---.. 9 ----.
[ { "input": "3\n...--\n.....\n---..\n", "output": "358\n" }, { "input": "10\n-----\n.----\n..---\n...--\n....-\n.....\n-....\n--...\n---..\n----.\n", "output": "0123456789\n" } ]
https://atcoder.jp/contests/codequeen2024-final-N9tn8QqD/tasks/codequeen2024_final_c
問題文 高橋君は AtCoder Land にある屋外アトラクションに K 回乗ろうとしています。このアトラクションの一回の所要時間は T です。 現在の時刻は 0 です。時刻 0 から N までの降水量が与えられます。時刻 i から時刻 i+1 までの降水量は P_i です ( 0\leq i\lt N )。アトラクションには時刻 0,1,…,N−T に乗ることができます。時刻 t にアトラクションに乗ると時刻 t+T にアトラクションから降りることができ、アトラクションに乗っている間に P_t+P_{t+1}+\dots+P_{t+T-1} だけ濡れます。 高橋君はアトラクションに乗っている間にできるだけ雨に濡れないようにしたい...
[ { "input": "8 3 2\n3 5 10 4 1 7 3 9\n", "output": "23\n" }, { "input": "5 1 3\n1000 1 10000 100 10\n", "output": "10101\n" }, { "input": "15 5 2\n401054171 63773035 986525245 157986893 799814573 139201145 649233932 351289844 409065258 406122133 957285954 529460482 21179081 795984182 7278...
https://atcoder.jp/contests/codequeen2024-final-N9tn8QqD/tasks/codequeen2024_final_d
問題文 AtCoder Land には N 個の地点と M 個の道があります。 i 個目の道は地点 a_i と b_i を双方向に結び、通過するのに d_i 分かかります。 これから、AtCoder Land で K 個のイベントが開催されます。 i 個目のイベントに参加するには、時刻 t_i 分に地点 c_i にいる必要があります。イベントにかかる時間は 0 分です。 あなたは、時刻 0 分に地点 1 にいます。適切に行動したとき、最大で何個のイベントに参加できるか求めてください。
[ { "input": "3 3 3\n1 2 1\n1 3 3\n2 3 7\n1 8\n2 2\n3 7\n", "output": "2\n" }, { "input": "1 0 2\n1 1\n1 100\n", "output": "2\n" }, { "input": "5 8 10\n1 2 149622151\n1 4 177783960\n4 5 118947237\n1 3 33222944\n1 5 295060863\n3 5 110881471\n2 3 34104208\n3 4 273071547\n2 650287940\n4 83929...
https://atcoder.jp/contests/codequeen2024-final-N9tn8QqD/tasks/codequeen2024_final_e
問題文 高橋くん一行は、AtCoder Land に行くためにランド内にあるホテルに泊まることにしました。 N 人の人と M 個のランクが付いた部屋があります。 i 番目の人はランクが A_i 以上の部屋に泊まりたいと考えています。 また、 i 番目の部屋のランクは R_i 、定員は B_i 人、客室料金は C_i 円です。 C_i 円払うことで、 B_i 人以下であれば何人でも i 番目の部屋に泊まることができます。 N 人全員が部屋に泊まることが可能か判定し、可能な場合必要な金額の総和の最小値を求めてください。
[ { "input": "4 3\n3 5 1 4\n5 3 3\n3 1 1\n2 3 2\n", "output": "4\n" }, { "input": "8 5\n2 5 1 5 2 1 2 4\n4 2 5\n7 2 4\n7 4 2\n1 4 7\n3 3 8\n", "output": "11\n" }, { "input": "10 1\n1 1 1 1 1 1 1 1 1 1\n10 4 1\n", "output": "-1\n" } ]
https://atcoder.jp/contests/codequeen2024-final-N9tn8QqD/tasks/codequeen2024_final_f
問題文 AtCoder Land で高橋君と青木君はイチゴの乗ったケーキを食べることになりました。 AtCoder Landのケーキは円形で、 N 個の半径方向の切れ込みによって N 個の扇形ピースに区切られています。 切れ込みを時計回りの順に切れ込み 1 , 切れ込み 2 , \ldots , 切れ込み N と番号をふったとき、時計回りに切れ込み i (1 \leq i \leq N-1) から切れ込み i+1 までの間の部分をピース i と呼びます。また、時計回りに切れ込み N から切れ込み 1 までの間の部分をピース N と呼びます。 ピース i (1 \leq i \leq N) の上には A_i 個のイチゴが乗っています。...
[ { "input": "3\n3 8 5\n", "output": "2\n" }, { "input": "15\n4096 64 512 1 256 16384 8 1024 2048 2 128 32 4 16 8192\n", "output": "15\n" } ]
https://atcoder.jp/contests/codequeen2024-final-N9tn8QqD/tasks/codequeen2024_final_g
問題文 高橋くん一行は、AtCoder Land 内のアイス屋さんにやってきました。 アイス屋さんには N 種類のフレーバーのアイスがあり、アイスはそれぞれ十分な量の在庫があります。 このアイス屋さんでは、 5 段重ねのアイスを購入することができます。 使う 5 つのフレーバーは(重複も含めて)自由に選ぶことができますが、あるアイスの上に直接同じ味のアイスを重ねることはできません。 つまり、このアイス屋さんで購入できる 5 段重ねのアイスは N\times(N-1) ^ 4 通りあります。 高橋くんはこのアイス屋さんのクーポンを持っており、 i=1,2,\ldots,N すべてに対して i 番目のフレーバーのアイスを注文した数が...
[ { "input": "5\n3 1 4 2 5\n", "output": "3\n1 2 1 3 1\n3 4 5 3 5\n5 3 5 4 5\n" }, { "input": "3\n1 2 1000\n", "output": "1\n3 1 3 2 3\n" }, { "input": "1\n3\n", "output": "0\n" }, { "input": "10\n2 1 8 6 1 2 1 6 9 1\n", "output": "7\n1 2 1 3 4\n3 4 3 4 3\n3 4 3 4 3\n3 4 5 ...
https://atcoder.jp/contests/codequeen2024-final-N9tn8QqD/tasks/codequeen2024_final_h
問題文 AtCoder Land には N 個のアトラクションがあります。 i 番目のアトラクションには、以下の 2 通りの搭乗方法があります。 通常通り搭乗する。 A_i 分後に搭乗が終了する。 ファストパスを使って搭乗する。 B_i 分後に搭乗が終了する。このとき、ファストパスが 1 枚消費される。 あなたはファストパスを K 枚持っています。 同じアトラクションに複数回搭乗しないものとすると、 T 分後までに最大でいくつのアトラクションに搭乗できますか? 但し、アトラクションを乗り換える時間は無視できること、最後に搭乗するアトラクションについて T 分後までに搭乗が終了している必要があることに注意してください。
[ { "input": "5 2 20\n7 4\n10 8\n3 3\n8 7\n9 5\n", "output": "4\n" }, { "input": "5 5 1\n1000000000000 1000000000000\n1000000000000 1000000000000\n1000000000000 1000000000000\n1000000000000 1000000000000\n1000000000000 1000000000000\n", "output": "0\n" }, { "input": "5 5 100000000000000000...
https://atcoder.jp/contests/abc364/tasks/abc364_a
Problem Statement Takahashi is planning to eat N dishes. The i -th dish he plans to eat is sweet if S_i = sweet , and salty if S_i = salty . If he eats two sweet dishes consecutively, he will feel sick and be unable to eat any more dishes. Determine whether he can eat all the dishes.
[ { "input": "5\nsalty\nsweet\nsalty\nsalty\nsweet\n", "output": "Yes\n" }, { "input": "4\nsweet\nsalty\nsweet\nsweet\n", "output": "Yes\n" }, { "input": "6\nsalty\nsweet\nsweet\nsalty\nsweet\nsweet\n", "output": "No\n" } ]
https://atcoder.jp/contests/abc364/tasks/abc364_b
Problem Statement There is a grid with H rows and W columns. Let (i, j) denote the cell at the i -th row from the top and j -th column from the left. Cell (i, j) is empty if C_{i, j} is . , and not empty if C_{i, j} is # . Takahashi is currently at cell (S_i, S_j) , and he will act according to the following rules for ...
[ { "input": "2 3\n2 1\n.#.\n...\nULDRU\n", "output": "2 2\n" }, { "input": "4 4\n4 2\n....\n.#..\n...#\n....\nDUUUURULRD\n", "output": "2 4\n" }, { "input": "6 6\n1 1\n.#####\n######\n######\n######\n######\n######\nRURLDLULLRULRDL\n", "output": "1 1\n" } ]
https://atcoder.jp/contests/abc364/tasks/abc364_c
Problem Statement There are N dishes, and the i -th dish has a sweetness of A_i and a saltiness of B_i . Takahashi plans to arrange these N dishes in any order he likes and eat them in that order. He will eat the dishes in the arranged order, but he will stop eating as soon as the total sweetness of the dishes he has e...
[ { "input": "4 7 18\n2 3 5 1\n8 8 1 4\n", "output": "2\n" }, { "input": "5 200000000000000 200000000000000\n1 1 1 1 1\n2 2 2 2 2\n", "output": "5\n" }, { "input": "8 30 30\n1 2 3 4 5 6 7 8\n8 7 6 5 4 3 2 1\n", "output": "6\n" } ]
https://atcoder.jp/contests/abc364/tasks/abc364_d
Problem Statement There are N+Q points A_1,\dots,A_N,B_1,\dots,B_Q on a number line, where point A_i has a coordinate a_i and point B_j has a coordinate b_j . For each j=1,2,\dots,Q , answer the following question: Let X be the point among A_1,A_2,\dots,A_N that is the k_j -th closest to point B_j . Find the distance b...
[ { "input": "4 3\n-3 -1 5 6\n-2 3\n2 1\n10 4\n", "output": "7\n3\n13\n" }, { "input": "2 2\n0 0\n0 1\n0 2\n", "output": "0\n0\n" }, { "input": "10 5\n-84 -60 -41 -100 8 -8 -52 -62 -61 -76\n-52 5\n14 4\n-2 6\n46 2\n26 7\n", "output": "11\n66\n59\n54\n88\n" } ]
https://atcoder.jp/contests/abc364/tasks/abc364_e
Problem Statement Takahashi has prepared N dishes for Snuke. The dishes are numbered from 1 to N , and dish i has a sweetness of A_i and a saltiness of B_i . Takahashi can arrange these dishes in any order he likes. Snuke will eat the dishes in the order they are arranged, but if at any point the total sweetness of the...
[ { "input": "4 8 4\n1 5\n3 2\n4 1\n5 3\n", "output": "3\n" }, { "input": "2 1 1\n3 2\n3 2\n", "output": "1\n" }, { "input": "2 100 100\n3 2\n3 2\n", "output": "2\n" }, { "input": "6 364 463\n230 381\n154 200\n328 407\n339 94\n193 10\n115 309\n", "output": "3\n" } ]
https://atcoder.jp/contests/abc364/tasks/abc364_f
Problem Statement There is a graph with N + Q vertices, numbered 1, 2, \ldots, N + Q . Initially, the graph has no edges. For this graph, perform the following operation for i = 1, 2, \ldots, Q in order: For each integer j satisfying L_i \leq j \leq R_i , add an undirected edge with cost C_i between vertices N + i and ...
[ { "input": "4 3\n1 2 2\n1 3 4\n2 4 5\n", "output": "22\n" }, { "input": "6 2\n1 2 10\n4 6 10\n", "output": "-1\n" }, { "input": "200000 4\n1 200000 1000000000\n1 200000 998244353\n1 200000 999999999\n1 200000 999999999\n", "output": "199651870599998\n" } ]
https://atcoder.jp/contests/abc364/tasks/abc364_g
Problem Statement The Country of AtCoder consists of N cities and M roads connecting them, and one can travel between any two cities by traversing some roads. The cities are numbered from 1 to N , and the roads are numbered from 1 to M . Road i connects cities A_i and B_i bidirectionally. Due to increasing traffic in ...
[ { "input": "4 5 3\n1 4 3\n3 4 4\n1 2 4\n2 3 2\n1 3 1\n", "output": "3\n6\n" }, { "input": "4 3 2\n2 4 28\n1 4 56\n1 3 82\n", "output": "84\n82\n56\n" }, { "input": "6 12 4\n2 6 68\n2 5 93\n4 6 28\n2 4 89\n3 6 31\n1 3 10\n1 2 53\n3 5 1\n3 5 74\n3 4 22\n4 5 80\n3 4 35\n", "output": "85...
https://atcoder.jp/contests/ahc035/tasks/ahc035_a
Problem Statement There is a field represented by an N \times N grid. Let (0, 0) be the coordinates of the top-left square, and (i, j) be the coordinates of the square located i squares down and j squares to the right from there. You are given 2N(N-1) grain seeds. There are M evaluation criteria, and each seed k has...
[]
https://atcoder.jp/contests/abc363/tasks/abc363_a
Problem Statement In AtCoder, a user's rating is given as a positive integer, and based on this value, a certain number of ^ is displayed. Specifically, when the rating is between 1 and 399 , inclusive, the display rules are as follows: When the rating is between 1 and 99 , inclusive, ^ is displayed once. When the rat...
[ { "input": "123\n", "output": "77\n" }, { "input": "250\n", "output": "50\n" } ]
https://atcoder.jp/contests/abc363/tasks/abc363_b
Problem Statement There are N people, and the current hair length of the i -th person (1 \leq i \leq N) is L_i . Each person's hair grows by 1 per day. Print the number of days after which the number of people whose hair length is at least T becomes P or more for the first time. If there are already P or more people wh...
[ { "input": "5 10 3\n3 11 1 6 2\n", "output": "7\n" }, { "input": "2 5 2\n10 10\n", "output": "0\n" }, { "input": "3 10 1\n1 2 3\n", "output": "7\n" } ]
https://atcoder.jp/contests/abc363/tasks/abc363_c
Problem Statement You are given a string S of length N consisting only of lowercase English letters. Find the number of strings obtained by permuting the characters of S (including the string S itself) that do not contain a palindrome of length K as a substring. Here, a string T of length N is said to "contain a palind...
[ { "input": "3 2\naab\n", "output": "1\n" }, { "input": "5 3\nzzyyx\n", "output": "16\n" }, { "input": "10 5\nabcwxyzyxw\n", "output": "440640\n" } ]
https://atcoder.jp/contests/abc363/tasks/abc363_d
Problem Statement A non-negative integer X is called a palindrome number if its decimal representation (without leading zeros) is a palindrome. For example, 363 , 12344321 , and 0 are all palindrome numbers. Find the N -th smallest palindrome number.
[ { "input": "46\n", "output": "363\n" }, { "input": "1\n", "output": "0\n" }, { "input": "1000000000000000000\n", "output": "90000000000000000000000000000000009\n" } ]
https://atcoder.jp/contests/abc363/tasks/abc363_e
Problem Statement There is an island of size H \times W , surrounded by the sea. The island is divided into H rows and W columns of 1 \times 1 sections, and the elevation of the section at the i -th row from the top and the j -th column from the left (relative to the current sea level) is A_{i,j} . Starting from now, t...
[ { "input": "3 3 5\n10 2 10\n3 1 4\n10 5 10\n", "output": "9\n7\n6\n5\n4\n" }, { "input": "3 5 3\n2 2 3 3 3\n2 1 2 1 3\n2 2 3 3 3\n", "output": "15\n7\n0\n" } ]
https://atcoder.jp/contests/abc363/tasks/abc363_f
Problem Statement You are given an integer N . Print a string S that satisfies all of the following conditions. If no such string exists, print -1 . S is a string of length between 1 and 1000 , inclusive, consisting of the characters 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , and * (multiplication symbol). S is a palindrome. ...
[ { "input": "363\n", "output": "11*3*11\n" }, { "input": "101\n", "output": "-1\n" }, { "input": "3154625100\n", "output": "2*57*184481*75*2\n" } ]
https://atcoder.jp/contests/abc363/tasks/abc363_g
Problem Statement You are given two sequences of length N : D=(D_1, D_2, \dots, D_N) and P=(P_1, P_2, \dots, P_N) . Process Q queries in the order they are given. Each query is given in the following format: c x y : Change D_c to x and P_c to y . Then, solve the following problem and print the answer. There are N jobs ...
[ { "input": "3 2\n1 2 3\n3 6 3\n3 1 4\n2 3 9\n", "output": "10\n13\n" }, { "input": "5 1\n1 2 3 4 5\n1000000000 1000000000 1000000000 1000000000 1000000000\n1 1 1000000000\n", "output": "5000000000\n" }, { "input": "10 10\n6 2 4 1 5 1 6 6 5 3\n45 65 71 52 86 52 48 60 40 98\n5 6 5\n8 4 34\...
https://atcoder.jp/contests/abc362/tasks/abc362_a
Problem Statement Takahashi came to a store to buy a pen. Here, a red pen costs R yen, a green pen costs G yen, and a blue pen costs B yen. Takahashi dislikes the color C . If C is Red , he cannot buy a red pen; if C is Green , he cannot buy a green pen; and if C is Blue , he cannot buy a blue pen. Determine the minimu...
[ { "input": "20 30 10\nBlue\n", "output": "20\n" }, { "input": "100 100 100\nRed\n", "output": "100\n" }, { "input": "37 39 93\nBlue\n", "output": "37\n" } ]
https://atcoder.jp/contests/abc362/tasks/abc362_b
Problem Statement In the xy -plane, there are three points A(x_A, y_A) , B(x_B, y_B) , and C(x_C, y_C) that are not collinear. Determine whether the triangle ABC is a right triangle.
[ { "input": "0 0\n4 0\n0 3\n", "output": "Yes\n" }, { "input": "-4 3\n2 1\n3 4\n", "output": "Yes\n" }, { "input": "2 4\n-3 2\n1 -2\n", "output": "No\n" } ]
https://atcoder.jp/contests/abc362/tasks/abc362_c
Problem Statement You are given N pairs of integers (L_1, R_1), (L_2, R_2), \ldots, (L_N, R_N) . Determine whether there exists a sequence of N integers X = (X_1, X_2, \ldots, X_N) that satisfies the following conditions, and print one such sequence if it exists. L_i \leq X_i \leq R_i for each i = 1, 2, \ldots, N . \di...
[ { "input": "3\n3 5\n-4 1\n-2 3\n", "output": "Yes\n4 -3 -1\n" }, { "input": "3\n1 2\n1 2\n1 2\n", "output": "No\n" }, { "input": "6\n-87 12\n-60 -54\n2 38\n-76 6\n87 96\n-17 38\n", "output": "Yes\n-66 -57 31 -6 89 9\n" } ]
https://atcoder.jp/contests/abc362/tasks/abc362_d
Problem Statement You are given a simple connected undirected graph with N vertices and M edges. Each vertex i\,(1\leq i \leq N) has a weight A_i . Each edge j\,(1\leq j \leq M) connects vertices U_j and V_j bidirectionally and has a weight B_j . The weight of a path in this graph is defined as the sum of the weights o...
[ { "input": "3 3\n1 2 3\n1 2 1\n1 3 6\n2 3 2\n", "output": "4 9\n" }, { "input": "2 1\n0 1\n1 2 3\n", "output": "4\n" }, { "input": "5 8\n928448202 994752369 906965437 942744902 907560126\n2 5 975090662\n1 2 908843627\n1 5 969061140\n3 4 964249326\n2 3 957690728\n2 4 942986477\n4 5 948404...
https://atcoder.jp/contests/abc362/tasks/abc362_e
Problem Statement You are given a sequence A = (A_1, A_2, \dots, A_N) of length N . For each k = 1, 2, \dots, N , find the number, modulo 998244353 , of (not necessarily contiguous) subsequences of A of length k that are arithmetic sequences. Two subsequences are distinguished if they are taken from different positions...
[ { "input": "5\n1 2 3 2 3\n", "output": "5 10 3 0 0\n" }, { "input": "4\n1 2 3 4\n", "output": "4 6 2 1\n" }, { "input": "1\n100\n", "output": "1\n" } ]
https://atcoder.jp/contests/abc362/tasks/abc362_f
Problem Statement You are given a tree T with N vertices. The vertices are numbered 1 to N , and the i -th edge (1 \leq i \leq N-1) connects vertices u_i and v_i bidirectionally. Using T , define a complete graph G with N vertices as follows: The weight w(x,y) of the edge between vertices x and y in G is the shortest d...
[ { "input": "4\n1 2\n2 3\n3 4\n", "output": "2 4\n1 3\n" }, { "input": "3\n1 2\n2 3\n", "output": "1 3\n" } ]
https://atcoder.jp/contests/abc362/tasks/abc362_g
Problem Statement You are given a string S consisting of lowercase English letters. You are also given Q queries to process sequentially. The i -th query is described as follows: A string T_i consisting of lowercase English letters is given. Print the number of substrings of S that equal T_i . Two substrings are distin...
[ { "input": "missisippi\n5\ni\ns\na\nis\nmissisippi\n", "output": "4\n3\n0\n2\n1\n" }, { "input": "aaaaaa\n6\na\naa\naaa\naaaa\naaaaa\naaaaaa\n", "output": "6\n5\n4\n3\n2\n1\n" } ]
https://atcoder.jp/contests/awtf2024-open/tasks/awtf2024_a
Problem Statement There are N slimes on a number line, and the i -th slime is at coordinate A_i . All these coordinates are distinct. Each slime has a weight of 1 . Also, you are given an integer K . First, you will choose K slimes and remove the others from the number line. Then, from time 0 , the chosen slimes wi...
[ { "input": "3 2\n0 1 2\n", "output": "1.00000000000000000000\n" }, { "input": "4 3\n0 1 4 9\n", "output": "2.83333333333333333333\n" }, { "input": "4 4\n0 1 2 3\n", "output": "0.50000000000000000000\n" }, { "input": "20 6\n0 3441380 120768398 229897071 231209282 232046760 254...
https://atcoder.jp/contests/awtf2024-open/tasks/awtf2024_b
Problem Statement You are given a string S of length N consisting of 0 and 1 . We define an inversion pair as a pair of integers (i, j) ( 1 \leq i < j \leq N ) such that the i -th character of S is 1 and the j -th character of S is 0 . As long as there is an inversion pair in S , perform the following operation: Rando...
[ { "input": "2\n10\n", "output": "1\n" }, { "input": "3\n110\n", "output": "499122178\n" }, { "input": "1\n0\n", "output": "0\n" }, { "input": "10\n1011000010\n", "output": "133099253\n" }, { "input": "100\n0101110010001000111000111001001101001100000111110001010010...
https://atcoder.jp/contests/awtf2024-open/tasks/awtf2024_c
Problem Statement Solve the following problem for T test cases. You are currently at coordinate 0 on a number line, and you want to reach coordinate L . You will use a car for the movement. This car runs on two types of fuel: types 1 and 2 . For each type, the car has a fuel tank of that type with a capacity of C liter...
[ { "input": "5\n1 10 4\n7\n1\n1 10 6\n7\n1\n2 12 3\n5 7\n1 1\n2 12 3\n5 7\n1 2\n20 749013197 23809523\n46981984 70791437 118235723 132421762 180040807 203849360 251468335 275277857 322889975 346699150 394318091 418113855 465732891 489532137 537144103 558852533 606466719 630275002 677584754 701394209\n1 2 2 1 1 2...
https://atcoder.jp/contests/awtf2024-open/tasks/awtf2024_d
Problem Statement You are given a permutation P=(P_1,P_2,\cdots,P_N) of (1,2,\cdots,N) . You want to perform zero or more swaps of adjacent elements so that P satisfies the following condition: The number of indices i such that P_i > P_{i+1} is at most 1 . Find the minimum number of swaps required.
[ { "input": "3\n3 2 1\n", "output": "1\n" }, { "input": "4\n2 4 1 3\n", "output": "0\n" }, { "input": "6\n2 3 1 6 4 5\n", "output": "1\n" }, { "input": "20\n8 13 6 11 20 3 12 18 17 4 10 1 7 16 19 5 2 15 14 9\n", "output": "36\n" } ]
https://atcoder.jp/contests/awtf2024-open/tasks/awtf2024_e
Problem Statement Solve the following problem for T test cases. There is a board with N rows and N columns. Let (i,j) denote the cell at the i -th row from the top and j -th column from the left. Initially, all cells are colorless. You have N^2 stamps. For each pair of integers (h,w) ( 1 \leq h,w \leq N ), there is one...
[ { "input": "4\n2 2\n2 2 1 1\n1 2 2 1\n2 0\n3 3\n3 3 1 1\n3 2 1 2\n2 3 1 1\n5 15\n5 5 1 1\n4 5 2 1\n5 4 1 1\n4 4 2 1\n3 5 3 1\n2 5 4 1\n1 5 4 1\n5 3 1 1\n3 4 3 1\n2 4 3 1\n4 3 2 1\n1 4 4 1\n3 3 3 1\n2 3 4 1\n1 3 5 1\n", "output": "2 1 1 1\n1 1 2 1\n\n2 2 1 1\n2 1 1 1\n1 2 1 1\n1 1 1 1\n\n2 2 1 2\n3 1 1 2\n1 ...
https://atcoder.jp/contests/awtf2024/tasks/awtf2024_a
Problem Statement There are N slimes on a number line, and the i -th slime is at coordinate A_i . All these coordinates are distinct. Each slime has a weight of 1 . Also, you are given an integer K . First, you will choose K slimes and remove the others from the number line. Then, from time 0 , the chosen slimes wi...
[ { "input": "3 2\n0 1 2\n", "output": "1.00000000000000000000\n" }, { "input": "4 3\n0 1 4 9\n", "output": "2.83333333333333333333\n" }, { "input": "4 4\n0 1 2 3\n", "output": "0.50000000000000000000\n" }, { "input": "20 6\n0 3441380 120768398 229897071 231209282 232046760 254...
https://atcoder.jp/contests/awtf2024/tasks/awtf2024_b
Problem Statement You are given a string S of length N consisting of 0 and 1 . We define an inversion pair as a pair of integers (i, j) ( 1 \leq i < j \leq N ) such that the i -th character of S is 1 and the j -th character of S is 0 . As long as there is an inversion pair in S , perform the following operation: Rando...
[ { "input": "2\n10\n", "output": "1\n" }, { "input": "3\n110\n", "output": "499122178\n" }, { "input": "1\n0\n", "output": "0\n" }, { "input": "10\n1011000010\n", "output": "133099253\n" }, { "input": "100\n0101110010001000111000111001001101001100000111110001010010...
https://atcoder.jp/contests/awtf2024/tasks/awtf2024_c
Problem Statement Solve the following problem for T test cases. You are currently at coordinate 0 on a number line, and you want to reach coordinate L . You will use a car for the movement. This car runs on two types of fuel: types 1 and 2 . For each type, the car has a fuel tank of that type with a capacity of C liter...
[ { "input": "5\n1 10 4\n7\n1\n1 10 6\n7\n1\n2 12 3\n5 7\n1 1\n2 12 3\n5 7\n1 2\n20 749013197 23809523\n46981984 70791437 118235723 132421762 180040807 203849360 251468335 275277857 322889975 346699150 394318091 418113855 465732891 489532137 537144103 558852533 606466719 630275002 677584754 701394209\n1 2 2 1 1 2...
https://atcoder.jp/contests/awtf2024/tasks/awtf2024_d
Problem Statement You are given a permutation P=(P_1,P_2,\cdots,P_N) of (1,2,\cdots,N) . You want to perform zero or more swaps of adjacent elements so that P satisfies the following condition: The number of indices i such that P_i > P_{i+1} is at most 1 . Find the minimum number of swaps required.
[ { "input": "3\n3 2 1\n", "output": "1\n" }, { "input": "4\n2 4 1 3\n", "output": "0\n" }, { "input": "6\n2 3 1 6 4 5\n", "output": "1\n" }, { "input": "20\n8 13 6 11 20 3 12 18 17 4 10 1 7 16 19 5 2 15 14 9\n", "output": "36\n" } ]
https://atcoder.jp/contests/awtf2024/tasks/awtf2024_e
Problem Statement Solve the following problem for T test cases. There is a board with N rows and N columns. Let (i,j) denote the cell at the i -th row from the top and j -th column from the left. Initially, all cells are colorless. You have N^2 stamps. For each pair of integers (h,w) ( 1 \leq h,w \leq N ), there is one...
[ { "input": "4\n2 2\n2 2 1 1\n1 2 2 1\n2 0\n3 3\n3 3 1 1\n3 2 1 2\n2 3 1 1\n5 15\n5 5 1 1\n4 5 2 1\n5 4 1 1\n4 4 2 1\n3 5 3 1\n2 5 4 1\n1 5 4 1\n5 3 1 1\n3 4 3 1\n2 4 3 1\n4 3 2 1\n1 4 4 1\n3 3 3 1\n2 3 4 1\n1 3 5 1\n", "output": "2 1 1 1\n1 1 2 1\n\n2 2 1 1\n2 1 1 1\n1 2 1 1\n1 1 1 1\n\n2 2 1 2\n3 1 1 2\n1 ...
https://atcoder.jp/contests/abc361/tasks/abc361_a
Problem Statement You are given an integer sequence A of length N and integers K and X . Print the integer sequence B obtained by inserting the integer X immediately after the K -th element of the sequence A .
[ { "input": "4 3 7\n2 3 5 11\n", "output": "2 3 5 7 11\n" }, { "input": "1 1 100\n100\n", "output": "100 100\n" }, { "input": "8 8 3\n9 9 8 2 4 4 3 5\n", "output": "9 9 8 2 4 4 3 5 3\n" } ]
https://atcoder.jp/contests/abc361/tasks/abc361_b
Problem Statement You are trying to implement collision detection in a 3D game. In a 3 -dimensional space, let C(a,b,c,d,e,f) denote the cuboid with a diagonal connecting (a,b,c) and (d,e,f) , and with all faces parallel to the xy -plane, yz -plane, or zx -plane. (This definition uniquely determines C(a,b,c,d,e,f) .) G...
[ { "input": "0 0 0 4 5 6\n2 3 4 5 6 7\n", "output": "Yes\n" }, { "input": "0 0 0 2 2 2\n0 0 2 2 2 4\n", "output": "No\n" }, { "input": "0 0 0 1000 1000 1000\n10 10 10 100 100 100\n", "output": "Yes\n" } ]
https://atcoder.jp/contests/abc361/tasks/abc361_c
Problem Statement You are given a sequence A of length N . Freely choose exactly K elements from A and remove them, then concatenate the remaining elements in their original order to form a new sequence B . Find the minimum possible value of this: the maximum value of B minus the minimum value of B .
[ { "input": "5 2\n3 1 5 4 9\n", "output": "2\n" }, { "input": "6 5\n1 1 1 1 1 1\n", "output": "0\n" }, { "input": "8 3\n31 43 26 6 18 36 22 13\n", "output": "18\n" } ]
https://atcoder.jp/contests/abc361/tasks/abc361_d
Problem Statement There are N+2 cells arranged in a row. Let cell i denote the i -th cell from the left. There is one stone placed in each of the cells from cell 1 to cell N . For each 1 \leq i \leq N , the stone in cell i is white if S_i is W , and black if S_i is B . Cells N+1 and N+2 are empty. You can perform the f...
[ { "input": "6\nBWBWBW\nWWWBBB\n", "output": "4\n" }, { "input": "6\nBBBBBB\nWWWWWW\n", "output": "-1\n" }, { "input": "14\nBBBWBWWWBBWWBW\nWBWWBBWWWBWBBB\n", "output": "7\n" } ]
https://atcoder.jp/contests/abc361/tasks/abc361_e
Problem Statement In the nation of AtCoder, there are N cities numbered 1 to N and N-1 roads numbered 1 to N-1 . Road i connects cities A_i and B_i bidirectionally, and its length is C_i . Any pair of cities can be reached from each other by traveling through some roads. Find the minimum travel distance required to sta...
[ { "input": "4\n1 2 2\n1 3 3\n1 4 4\n", "output": "11\n" }, { "input": "10\n10 9 1000000000\n9 8 1000000000\n8 7 1000000000\n7 6 1000000000\n6 5 1000000000\n5 4 1000000000\n4 3 1000000000\n3 2 1000000000\n2 1 1000000000\n", "output": "9000000000\n" } ]
https://atcoder.jp/contests/abc361/tasks/abc361_f
Problem Statement How many integers x between 1 and N , inclusive, can be expressed as x = a^b using some positive integer a and a positive integer b not less than 2 ?
[ { "input": "99\n", "output": "12\n" }, { "input": "1000000000000000000\n", "output": "1001003332\n" } ]
https://atcoder.jp/contests/abc361/tasks/abc361_g
Problem Statement There are N stones placed on a 2 -dimensional plane. The i -th stone is located at coordinates (X_i, Y_i) . All stones are located at lattice points in the first quadrant (including the axes). Count the number of lattice points (x, y) where no stone is placed and it is impossible to reach (-1, -1) fro...
[ { "input": "5\n1 0\n0 1\n2 3\n1 2\n2 1\n", "output": "1\n" }, { "input": "0\n", "output": "0\n" }, { "input": "22\n0 1\n0 2\n0 3\n1 0\n1 4\n2 0\n2 2\n2 4\n3 0\n3 1\n3 2\n3 4\n5 1\n5 2\n5 3\n6 0\n6 4\n7 0\n7 4\n8 1\n8 2\n8 3\n", "output": "6\n" } ]
https://atcoder.jp/contests/abc360/tasks/abc360_a
Problem Statement Takahashi eats three plates for breakfast: rice, miso soup, and salad. His table is long and narrow, so he arranged the three plates in a row. The arrangement is given by a string S , where the i -th plate from the left is rice if S_i is R , miso soup if S_i is M , and salad if S_i is S . Determine wh...
[ { "input": "RSM\n", "output": "Yes\n" }, { "input": "SMR\n", "output": "No\n" } ]
https://atcoder.jp/contests/abc360/tasks/abc360_b
Problem Statement You are given two strings S and T consisting of lowercase English letters. Determine if there exists a pair of integers c and w such that 1 \leq c \leq w < |S| and the following condition is satisfied. Here, |S| denotes the length of the string S . Note that w must be less than |S| . If S is split at ...
[ { "input": "atcoder toe\n", "output": "Yes\n" }, { "input": "beginner r\n", "output": "No\n" }, { "input": "verticalreading agh\n", "output": "No\n" } ]
https://atcoder.jp/contests/abc360/tasks/abc360_c
Problem Statement There are N boxes numbered 1 to N and N items numbered 1 to N . Item i (1 \leq i \leq N) is in box A_i and has a weight of W_i . You can repeatedly perform the operation of choosing an item and moving it to another box zero or more times. If the weight of the item being moved is w , the cost of the op...
[ { "input": "5\n2 2 3 3 5\n33 40 2 12 16\n", "output": "35\n" }, { "input": "12\n3 6 7 4 12 4 8 11 11 1 8 11\n3925 9785 9752 3587 4013 1117 3937 7045 6437 6208 3391 6309\n", "output": "17254\n" } ]
https://atcoder.jp/contests/abc360/tasks/abc360_d
Problem Statement There are N ants on a number line, labeled 1 to N . Ant i (1 \leq i \leq N) starts at coordinate X_i and faces either a positive or negative direction. Initially, all ants are at distinct coordinates. The direction each ant is facing is represented by a binary string S of length N , where ant i is fac...
[ { "input": "6 3\n101010\n-5 -1 0 1 2 4\n", "output": "5\n" }, { "input": "13 656320850\n0100110011101\n-900549713 -713494784 -713078652 -687818593 -517374932 -498415009 -472742091 -390030458 -379340552 -237481538 -44636942 352721061 695864366\n", "output": "14\n" } ]
https://atcoder.jp/contests/abc360/tasks/abc360_e
Problem Statement There are N - 1 white balls and one black ball. These N balls are arranged in a row, with the black ball initially at the leftmost position. Takahashi will perform the following operation exactly K times. Choose an integer uniformly at random between 1 and N , inclusive, twice. Let a and b the chosen ...
[ { "input": "2 1\n", "output": "499122178\n" }, { "input": "3 2\n", "output": "554580198\n" }, { "input": "4 4\n", "output": "592707587\n" } ]
https://atcoder.jp/contests/abc360/tasks/abc360_f
Problem Statement You are given N intervals numbered 1 to N . Interval i is [L_i, R_i] . Two intervals [l_a, r_a] and [l_b, r_b] are said to intersect if and only if they satisfy either (l_a < l_b < r_a < r_b) or (l_b < l_a < r_b < r_a) . Define f(l, r) as the number of intervals i ( 1 \leq i \leq N ) that intersect wi...
[ { "input": "5\n1 7\n3 9\n7 18\n10 14\n15 20\n", "output": "4 11\n" }, { "input": "11\n856977192 996441446\n298251737 935869360\n396653206 658841528\n710569907 929136831\n325371222 425309117\n379628374 697340458\n835681913 939343451\n140179224 887672320\n375607390 611397526\n93530028 581033295\n24961...
https://atcoder.jp/contests/abc360/tasks/abc360_g
Problem Statement You are given an integer sequence A of length N . Takahashi will perform the following operation exactly once: Choose an integer x between 1 and N , inclusive, and an arbitrary integer y . Replace A_x with y . Find the maximum possible length of a longest increasing subsequence (LIS) of A after perfor...
[ { "input": "4\n3 2 2 4\n", "output": "3\n" }, { "input": "5\n4 5 3 6 7\n", "output": "4\n" } ]
https://atcoder.jp/contests/arc180/tasks/arc180_a
Problem Statement You are given a string S of length N consisting of characters A and B . You can perform the following two types of operations zero or more times in any order: Choose a (contiguous) substring ABA in S and replace it with A . Choose a (contiguous) substring BAB in S and replace it with B . Find, modulo ...
[ { "input": "4\nABAB\n", "output": "2\n" }, { "input": "1\nA\n", "output": "1\n" }, { "input": "17\nBBABABAABABAAAABA\n", "output": "18\n" }, { "input": "100\nABAABAABABBABAABAABAABABBABBABBABBABBABBABBABBABBABBABBABBABBABBABAABABAABABBABBABABBABAABAABAABAABA\n", "output":...
https://atcoder.jp/contests/arc180/tasks/arc180_b
Problem Statement You are given a permutation P=(P_1,P_2,\cdots,P_N) of (1,2,\cdots,N) . Additionally, you are given an integer K . You can perform the following operation zero or more times: Choose integers l and r ( 1 \leq l < r \leq N ). Here, the pair (l,r) must satisfy all of the following conditions: K \leq r-l ...
[ { "input": "3 1\n3 2 1\n", "output": "3\n2 3\n1 3\n1 2\n" }, { "input": "5 4\n1 4 3 2 5\n", "output": "0\n" }, { "input": "4 2\n4 1 2 3\n", "output": "2\n1 4\n1 3\n" }, { "input": "10 5\n8 7 6 10 9 3 1 5 2 4\n", "output": "15\n3 8\n2 8\n3 10\n3 9\n1 8\n2 10\n2 9\n2 7\n1 1...
https://atcoder.jp/contests/arc180/tasks/arc180_c
Problem Statement You are given an integer sequence A=(A_1,A_2,\cdots,A_N) of length N . You will perform the following operation exactly once: Choose a non-empty subsequence of A (not necessarily contiguous) and replace it with its cumulative sums. More precisely, first choose a sequence of indices (i_1,i_2,\cdots,i_...
[ { "input": "3\n1 1 2\n", "output": "4\n" }, { "input": "4\n1 -1 1 -1\n", "output": "8\n" }, { "input": "5\n0 0 0 0 0\n", "output": "1\n" }, { "input": "40\n2 -2 1 3 -3 -1 -2 -3 0 -1 -2 0 -3 0 0 2 0 -1 2 -2 -2 -1 3 -2 -2 -2 2 3 2 -3 0 -2 2 1 3 0 -1 0 -2 -3\n", "output": "4...
https://atcoder.jp/contests/arc180/tasks/arc180_d
Problem Statement You are given an integer sequence A=(A_1,A_2,\cdots,A_N) of length N . Answer the following Q queries. The i -th query: You are given integers L_i and R_i . Solve the following problem for B=(A_{L_i},A_{L_i+1},\cdots,A_{R_i}) . Divide B into three non-empty contiguous subsequences. For each contiguo...
[ { "input": "7 5\n4 3 1 1 4 5 2\n1 7\n2 4\n3 5\n1 5\n4 7\n", "output": "10\n5\n6\n9\n8\n" }, { "input": "10 15\n8 3 8 10 1 5 3 1 6 4\n4 6\n2 5\n6 9\n8 10\n2 9\n4 10\n1 5\n1 8\n1 3\n4 8\n1 10\n2 10\n6 10\n2 6\n2 6\n", "output": "16\n14\n12\n11\n17\n17\n19\n14\n19\n14\n17\n17\n12\n16\n16\n" } ]
https://atcoder.jp/contests/arc180/tasks/arc180_e
Problem Statement You are given an integer sequence A=(A_1,A_2,\cdots,A_N) of length N . Here, it is guaranteed that 0 \leq A_i < i for each i . The score and cost of a permutation P=(P_1,P_2,\cdots,P_N) of (1,2,\cdots,N) are defined as follows: The score of P is the length of a longest increasing subsequence of P . ...
[ { "input": "4\n0 1 2 1\n", "output": "0 0 1 3\n" }, { "input": "3\n0 0 0\n", "output": "0 0 0\n" }, { "input": "5\n0 1 2 3 4\n", "output": "0 1 2 3 4\n" }, { "input": "11\n0 0 2 3 4 5 3 7 8 2 10\n", "output": "0 0 0 1 2 3 4 5 7 8 9\n" } ]
https://atcoder.jp/contests/arc180/tasks/arc180_f
Problem Statement You are given integers N and A . You will perform the following operations: Generate N real numbers uniformly at random between 0 and 1 , inclusive. All generations are independent, and the random numbers are uniformly distributed. Call the generated N real numbers x_1, x_2, \cdots, x_N in ascending o...
[ { "input": "2 1\n", "output": "666666673\n" }, { "input": "1 1\n", "output": "1\n" }, { "input": "2 2\n", "output": "500000005\n" }, { "input": "3 2\n", "output": "142857147\n" }, { "input": "5 3\n", "output": "758371066\n" }, { "input": "10000 12345\n...
https://atcoder.jp/contests/abc359/tasks/abc359_a
Problem Statement You are given N strings. The i -th string S_i (1 \leq i \leq N) is either Takahashi or Aoki . How many i are there such that S_i is equal to Takahashi ?
[ { "input": "3\nAoki\nTakahashi\nTakahashi\n", "output": "2\n" }, { "input": "2\nAoki\nAoki\n", "output": "0\n" }, { "input": "20\nAoki\nTakahashi\nTakahashi\nAoki\nAoki\nAoki\nAoki\nTakahashi\nAoki\nAoki\nAoki\nTakahashi\nTakahashi\nAoki\nTakahashi\nAoki\nAoki\nAoki\nAoki\nTakahashi\n", ...
https://atcoder.jp/contests/abc359/tasks/abc359_b
Problem Statement There are 2N people standing in a row, and the person at the i -th position from the left is wearing clothes of color A_i . Here, the clothes have N colors from 1 to N , and exactly two people are wearing clothes of each color. Find how many of the integers i=1,2,\ldots,N satisfy the following conditi...
[ { "input": "3\n1 2 1 3 2 3\n", "output": "2\n" }, { "input": "2\n1 1 2 2\n", "output": "0\n" }, { "input": "4\n4 3 2 3 2 1 4 1\n", "output": "3\n" } ]
https://atcoder.jp/contests/abc359/tasks/abc359_c
Problem Statement The coordinate plane is covered with 2\times1 tiles. The tiles are laid out according to the following rules: For an integer pair (i,j) , the square A _ {i,j}=\lbrace(x,y)\mid i\leq x\leq i+1\wedge j\leq y\leq j+1\rbrace is contained in one tile. When i+j is even, A _ {i,j} and A _ {i + 1,j} are conta...
[ { "input": "5 0\n2 5\n", "output": "5\n" }, { "input": "3 1\n4 1\n", "output": "0\n" }, { "input": "2552608206527595 5411232866732612\n771856005518028 7206210729152763\n", "output": "1794977862420151\n" } ]
https://atcoder.jp/contests/abc359/tasks/abc359_d
Problem Statement You are given a string S of length N consisting of characters A , B , and ? . You are also given a positive integer K . A string T consisting of A and B is considered a good string if it satisfies the following condition: No contiguous substring of length K in T is a palindrome. Let q be the number o...
[ { "input": "7 4\nAB?A?BA\n", "output": "1\n" }, { "input": "40 7\n????????????????????????????????????????\n", "output": "116295436\n" }, { "input": "15 5\nABABA??????????\n", "output": "0\n" }, { "input": "40 8\n?A?B??B?B?AA?A?B??B?A???B?BB?B???BA??BAA\n", "output": "259...
https://atcoder.jp/contests/abc359/tasks/abc359_e
Problem Statement You are given a sequence of positive integers of length N : H=(H _ 1,H _ 2,\dotsc,H _ N) . There is a sequence of non-negative integers of length N+1 : A=(A _ 0,A _ 1,\dotsc,A _ N) . Initially, A _ 0=A _ 1=\dotsb=A _ N=0 . Perform the following operations repeatedly on A : Increase the value of A _ 0 ...
[ { "input": "5\n3 1 4 1 5\n", "output": "4 5 13 14 26\n" }, { "input": "6\n1000000000 1000000000 1000000000 1000000000 1000000000 1000000000\n", "output": "1000000001 2000000001 3000000001 4000000001 5000000001 6000000001\n" }, { "input": "15\n748 169 586 329 972 529 432 519 408 587 138 2...
https://atcoder.jp/contests/abc359/tasks/abc359_f
Problem Statement You are given a sequence of integers A=(A_1,\ldots,A_N) . For a tree T with N vertices, define f(T) as follows: Let d_i be the degree of vertex i in T . Then, f(T)=\sum_{i=1}^N {d_i}^2 A_i . Find the minimum possible value of f(T) . The constraints guarantee the answer to be less than 2^{63} .
[ { "input": "4\n3 2 5 2\n", "output": "24\n" }, { "input": "3\n4 3 2\n", "output": "15\n" }, { "input": "7\n10 5 10 2 10 13 15\n", "output": "128\n" } ]
https://atcoder.jp/contests/abc359/tasks/abc359_g
Problem Statement You are given a tree with N vertices. The i -th edge connects vertices u_i and v_i bidirectionally. Additionally, you are given an integer sequence A=(A_1,\ldots,A_N) . Here, define f(i,j) as follows: If A_i = A_j , then f(i,j) is the minimum number of edges you need to traverse to move from vertex i ...
[ { "input": "4\n3 4\n4 2\n1 2\n2 1 1 2\n", "output": "4\n" }, { "input": "8\n8 6\n3 8\n1 4\n7 8\n4 5\n3 4\n8 2\n1 2 2 2 3 1 1 3\n", "output": "19\n" } ]
https://atcoder.jp/contests/npcapc_2024/tasks/npcapc_2024_a
問題文 英大文字と英小文字からなる長さ N の文字列のうち、 NPCAPC と npcapc の両方を部分文字列(連続でなくてもよい)として含むものの個数を 998244353 で割ったあまりを求めてください。 T 個のテストケースが与えられるので、それぞれについて解いてください。
[ { "input": "4\n12\n6\n5839\n123456\n", "output": "924\n0\n966252995\n432934749\n" }, { "input": "3\n123456789\n987654321\n999999999\n", "output": "333574957\n124462731\n163251704\n" } ]
https://atcoder.jp/contests/npcapc_2024/tasks/npcapc_2024_b
問題文 長さ N の正整数列 A=(A_1,A_2,\dots,A_N) が与えられます。 k=0,1,\dots,N について以下の問題を解いてください。 \lbrace 1,2,\dots,N\rbrace の部分集合 S であって以下の条件を満たすものの個数を 998244353 で割ったあまりを求めてください。 \left\vert T\right\vert=\left\vert S\right\vert-k を満たす S の部分集合 T であって \sum_{i \in T}A_{i}\ge M を満たすものが存在する。
[ { "input": "4 7\n3 1 5 2\n", "output": "6\n4\n1\n0\n0\n" }, { "input": "1 5\n7\n", "output": "1\n0\n" }, { "input": "9 18\n1 9 5 6 2 7 1 4 8\n", "output": "346\n309\n230\n126\n46\n10\n1\n0\n0\n0\n" } ]
https://atcoder.jp/contests/npcapc_2024/tasks/npcapc_2024_c
問題文 なむか君は友達のなぷか君と協力して問題 1 , 問題 2 , \dots , 問題 N の N 個の問題を全て解くことになりました。 最初二人とも疲れは 0 ですが、問題を 1 問解くとその問題を解いた人の疲れが 1 増えます。問題 i を疲れが j のときに解くと、なむか君は A_i+C_j 分かかり、なぷか君は B_i+D_j 分かかります。ただし、 2 人が同時に別の問題を解くことは出来ません。 なむか君となぷか君が N 個の問題を解く時間の総和の最小値を求めてください。
[ { "input": "3\n1 3 5\n6 4 2\n1 2 3\n1 2 3\n", "output": "10\n" }, { "input": "5\n2 4 3 1 2\n9 2 5 3 8\n1 2 8 3 2\n5 4 3 2 1\n", "output": "28\n" }, { "input": "8\n21 85 72 22 81 20 88 28\n75 22 78 92 55 56 73 44\n39 14 64 27 73 42 16 84\n27 7 91 85 69 95 70 27\n", "output": "621\n" ...
https://atcoder.jp/contests/npcapc_2024/tasks/npcapc_2024_d
問題文 長さ N の非負整数列 A=(A_1,A_2,\dots,A_N) と Q 個のクエリが与えられます。 i 個目のクエリは以下のような内容です。 A_{x_i} を y_i に変更し、その後の A について以下の問題の答えを求める。 白い箱と黒い箱と 1 から M の番号が付いた M 個のボールがあります。始め、全てのボールは白い箱に入っています。 ここで、あなたは以下の操作を N 回繰り返します。 1 \le x \le M を満たす整数 x を選ぶ。ボール x を今入っている箱からもう一方の箱に移動させる。 i 回目の操作終了後、黒い箱に入っているボールの番号は全て A_i 以下である必要があります。操作列としてあり得る...
[ { "input": "3 3 2\n1 3 1\n3 2\n1 3\n", "output": "5\n14\n" }, { "input": "6 8 1\n3 8 7 7 1 6\n1 4\n", "output": "2100\n" }, { "input": "12 10 8\n1 3 2 6 3 6 7 7 5 5 4 7\n12 4\n7 10\n4 2\n9 8\n9 9\n8 3\n4 9\n10 2\n", "output": "2741280\n3007680\n1503840\n1916160\n1972800\n728640\n1821...
https://atcoder.jp/contests/npcapc_2024/tasks/npcapc_2024_e
問題文 あなたは 2 次元平面を用いてゲームをします。始め、 -100 \le x \le 100,-100 \le y \le 0 を満たす格子点 (x,y) に駒が 1 個ずつ置かれています。 あなたは以下の操作を 0 回以上行うことが出来ます。 2 個の点の組 (a,b),(c,d) であって、 |a-c|+|b-d| = 1 かつ (a,b),(c,d) 両方に駒が 1 個以上あるものを選ぶ。 (a,b) にある駒 1 個を (c,d) を中心として時計回りか反時計周りに 90 度回転させた点に置き、 (c,d) にある駒を 1 個消す。(既に移動先の点に駒が置かれていても良い。) あなたの目標は操作が全て終わったときに y...
[ { "input": "1\n1\n", "output": "1\n1 0 0 0 0 1\n" } ]
https://atcoder.jp/contests/npcapc_2024/tasks/npcapc_2024_f
問題文 1 から N の番号がついた N 人の人が一列に並べられた M 個の椅子に座ります。左から i 番目の椅子を椅子 i と呼びます。人 i は椅子 A_i に座ります。 ある人が座った時に、その人の左右それぞれで最も近い座っている人のいる椅子の番号(それぞれない場合は 0,M+1 )を L,R としたとき、座った人のスコアを R - L とします。 N 人が順番に座る方法は N! 通りありますが、 N 人のスコアの総和としてあり得る最大値を求めてください。
[ { "input": "3 10\n3 7 10\n", "output": "28\n" }, { "input": "5 20\n3 10 11 14 17\n", "output": "73\n" }, { "input": "10 1000000000\n136909656 243332691 643531997 505919307 43553384 657638276 57213246 179732866 357373203 182482400\n", "output": "7649951260\n" } ]
https://atcoder.jp/contests/npcapc_2024/tasks/npcapc_2024_g
問題文 PCT 君は以下のような問題を作りました。 Common Segment N 個の区間 [L_1,R_1],[L_2,R_2],\dots,[L_N,R_N] が与えられます。ここで [L, R] は L 以上 R 以下の全ての整数からなる区間を意味します。 ここから 1 個以上の区間を選ぶ方法は 2^N-1 通りありますが、そのうち選んだ全ての区間の共通部分が空でないものの個数を 998244353 で割ったあまりを求めてください。 PCT 君は間違えてテストケースの L_i,R_i のうち一部の値をなくしてしまいました。困った彼のために以下の問題を解いてください。 Many Common Segment Testcase...
[ { "input": "3 3\n1 -1\n2 2\n2 3\n", "output": "18\n" }, { "input": "5 8\n1 7\n2 3\n4 8\n6 8\n1 5\n", "output": "15\n" }, { "input": "10 13\n4 -1\n-1 -1\n7 11\n-1 -1\n-1 -1\n-1 -1\n11 -1\n3 8\n-1 9\n-1 -1\n", "output": "841024210\n" } ]
https://atcoder.jp/contests/npcapc_2024/tasks/npcapc_2024_h
問題文 1 から N の番号がついた N 個のスイッチがあります。今全てのスイッチはオフになっています。 これからスイッチを自由な順番で 1 個ずつ押していきますが、それぞれのスイッチは壊れています。具体的には、スイッチ i は押すのに T_i 秒かかり、押すと以下のような挙動を示します。 確率 \frac{A_i}{B_i} でオンになる。 確率 1 - \frac{A_i}{B_i} で N 個のスイッチが全てオフになる。 スイッチがオンになるかどうかはスイッチを押す毎に独立に選択されます。また、あるスイッチを押している間他のスイッチを押すことは出来ません。 あなたの目標は出来るだけ早く全てのスイッチをオンにすることです。あなた...
[ { "input": "2\n3 3 5\n2 4 7\n", "output": "831870305\n" }, { "input": "5\n2 5 9\n6 4 7\n1 9 14\n17 8 13\n10 4 11\n", "output": "914017655\n" }, { "input": "8\n6 2 8\n3 1 8\n5 30 71\n7 9 58\n6 4 7\n6 9 25\n2 8 67\n6 6 55\n", "output": "923892723\n" } ]
https://atcoder.jp/contests/npcapc_2024/tasks/npcapc_2024_i
問題文 (1,\dots,N) の順列 (P_1,\dots,P_N) であって、以下の条件を満たすものの個数を 998244353 で割ったあまりを求めてください。 ある整数 i(1\le i\lt N) が存在して A_{P_1}+\dots+A_{P_i}=A_{P_{i+1}}+\dots+A_{P_N} が成立する。
[ { "input": "3\n4 9 5\n", "output": "4\n" }, { "input": "2\n100 100\n", "output": "2\n" }, { "input": "8\n3 2 6 3 1 2 4 5\n", "output": "11520\n" } ]
https://atcoder.jp/contests/npcapc_2024/tasks/npcapc_2024_j
問題文 (1,2,\dots,N) の順列が M 個与えられます。 i 個目の順列は P_i = (P_{i,1},P_{i,2},\dots,P_{i,N}) です。 あなたは数列 Q=(1,2,\dots,N) を持っています。そして、以下の操作を 0 回以上行うことが出来ます。 1 \le i \le M を満たす整数 i を選び、 Q を (Q_{P_{i,1}},Q_{P_{i,2}},\dots,Q_{P_{i,N}}) に更新する。 操作後の Q としてあり得る数列全てに対する転倒数の総和を 998244353 で割ったあまりを求めてください。
[ { "input": "3 2\n1 2 3\n2 3 1\n", "output": "4\n" }, { "input": "5 2\n3 4 5 1 2\n1 5 4 3 2\n", "output": "50\n" }, { "input": "30 12\n1 2 9 4 5 6 7 8 3 10 11 12 19 14 15 25 17 18 20 26 21 22 23 24 16 29 27 28 13 30\n9 2 27 4 5 10 7 8 1 25 11 12 24 14 15 16 17 18 19 20 21 22 23 28 6 26 3 ...
https://atcoder.jp/contests/npcapc_2024/tasks/npcapc_2024_k
問題文 NPCA 国は横一列に並んだ N 個のマスからなり、左から順に 1 から N の番号がつけられています。ここで、マス i の高さを H_i とします。始め、 H_1=H_2=\dots=H_N=0 となっています。 各 1\le i\le N-1 について、 H_i と H_{i+1} の差の絶対値が D_i 未満であるとき、マス i とマス i+1 の間で争いが起こってしまいます。さて、平和を愛する NPCA 国の王のなぷか君の目標はどの隣り合うマスの間でも争いが起きなくなることです。そのため、なぷか君は以下の魔法を 0 回以上かけることが出来ます。 H_i=H_{i+1}=\dots=H_{j} を満たす整数 i,j(1...
[ { "input": "4\n2 3 1\n", "output": "4\n" }, { "input": "3\n0 0\n", "output": "0\n" }, { "input": "10\n1 9 5 6 2 7 1 4 8\n", "output": "22\n" } ]
https://atcoder.jp/contests/npcapc_2024/tasks/npcapc_2024_l
問題文 長さ N-1 の広義単調増加である正整数列 X=(X_1,X_2,\dots,X_{N-1}) が与えられます。 N 頂点 M 辺単純連結無向グラフ G のコストを \sum_{i=1}^{N} \sum_{j=i+1}^{N} X_{d(i,j)} と定義します。ただし、 d(i,j) は G 上で頂点 i から頂点 j へ移動するまでに通る辺の本数としてあり得る最小値として定義します。 コストが最小になる N 頂点 M 辺単純連結無向グラフ G を 1 個構築してください。
[ { "input": "3 2\n4 5\n", "output": "1 2\n1 3\n" }, { "input": "4 6\n12 34 56\n", "output": "1 2\n1 3\n1 4\n2 3\n2 4\n3 4\n" } ]
https://atcoder.jp/contests/npcapc_2024/tasks/npcapc_2024_m
問題文 なむか君は長さ N の数列 A=(A_1,A_2,\dots, A_N) を、なむか君のあこがれの人は長さ M の数列 B=(B_1,B_2,\dots,B_M) を持っています。 なむか君はあこがれの人に近づくために A から異なる M 個の要素を選び、好きな順番で並べて長さ M の数列 C=(C_1, C_2,\dots,C_M) を作ります。 このとき、 \sum_{i=1}^M \left\vert B_i-C_i\right\vert としてあり得る最小値を求めてください。
[ { "input": "5 3\n2 6 5 1 1\n6 3 8\n", "output": "4\n" }, { "input": "3 2\n1 1 9\n1 1\n", "output": "0\n" }, { "input": "11 7\n13 21 9 5 16 32 15 29 20 40 4\n24 34 43 39 18 30 11\n", "output": "32\n" } ]
https://atcoder.jp/contests/npcapc_2024/tasks/npcapc_2024_n
問題文 各要素が 1 次の多項式である N 次正方行列 P(x) が与えられます。 P(x) の (i,j) 成分は a_{i,j} x + b_{i,j} です。 \prod_{i=0}^{M-1} P(2^ix) = P(x) P(2x) \dots P(2^{M-1}x) の (1,1) 成分 f(x) = \sum_{i=0}^{M} c_ix^i の各係数 c_0,c_1,\dots,c_M を \bmod\ 10^9 + 7 で求めてください。
[ { "input": "2 2\n1 2\n3 4\n2 0\n1 2\n", "output": "4\n8\n14\n" }, { "input": "4 10\n520471651 866160932 848899741 650346545\n756377215 402412491 920748640 255249004\n371442152 93295238 350011159 679848583\n528399020 957465601 22001245 407745834\n363922864 418156995 324388560 611306817\n671914474 323...
https://atcoder.jp/contests/npcapc_2024/tasks/npcapc_2024_o
問題文 NPCA 校には 2N 人の生徒がおり、各生徒には 1 から 2N の順番が付けられています。なぷか君は NPCA 校の教師で、生徒を N 人ずつの 2 つのクラスに分けることになりました。 ここで、クラス分けの不満度を以下のように定義します。 整数 i(1 \le i \le M) のうち、生徒 A_i と生徒 B_i が同じクラスにいるもの全てに対する 2^i の総和 なぷか君のために、不満度が最小となるクラス分けの方法を 1 つ構築してください。
[ { "input": "2 4\n1 3\n2 4\n1 4\n1 2\n", "output": "0101\n" }, { "input": "1 0\n", "output": "01\n" }, { "input": "3 7\n2 5\n1 3\n4 6\n2 6\n4 5\n2 4\n5 6\n", "output": "011010\n" } ]
https://atcoder.jp/contests/npcapc_2024/tasks/npcapc_2024_p
問題文 PCT 君は次のような問題を作りました。 Shuffle and Increasing 長さ N の正整数列 A=(A_1,A_2,\dots,A_N) が与えられます。 A を並び替えて得られる列のうち、 A_i < A_{i+1} を満たす i がちょうど M 個あるものの個数を 998244353 で割ったあまりを求めてください。 制約 1 \le N \le 30 0 \le M \le N-1 1 \le A_i \le N PCT 君は上記の問題で答えが X になる入力を作りたいです。そのような入力が存在するか判定し、存在するならば 1 個構築してください。 T 個のテストケースが与えられるので、それぞれについて...
[ { "input": "4\n4\n131\n333854876\n620963539\n", "output": "4 2\n1 3 3 2\n6 3\n6 2 6 4 5 1 \n17 10\n8 7 1 14 8 5 12 5 2 17 7 16 15 17 14 15 6 \n24 14\n16 8 14 18 15 16 21 4 10 14 3 4 22 8 16 11 22 17 11 5 12 2 13 18 \n" } ]
https://atcoder.jp/contests/ahc034/tasks/ahc034_a
Problem Statement There is an N \times N grid of land. Let (0,0) be the coordinates of the top-left square and (i,j) be the coordinates of the square located i squares down and j squares to the right from there. The height h_{i,j} of each square (i,j) is given as input. The total height of all squares is exactly 0 . ...
[ { "input": "20\n10 4 0 0 4 10 16 20 21 16 11 2 -7 -16 -23 -25 -23 -16 -7 2\n16 10 6 5 7 10 13 15 14 10 4 -4 -13 -21 -29 -32 -29 -22 -13 -3\n20 14 10 8 9 10 11 12 10 6 0 -7 -15 -24 -31 -33 -31 -25 -16 -8\n20 15 12 10 10 10 10 11 8 5 0 -5 -12 -20 -26 -29 -28 -23 -15 -7\n16 13 12 10 10 10 10 10 9 7 4 1 -4 -10 -16 ...
https://atcoder.jp/contests/abc358/tasks/abc358_a
Problem Statement Takahashi is heading to AtCoder Land. There is a signboard in front of him, and he wants to determine whether it says AtCoder Land. You are given two strings S and T separated by a space. Determine whether S= AtCoder and T= Land .
[ { "input": "AtCoder Land\n", "output": "Yes\n" }, { "input": "CodeQUEEN Land\n", "output": "No\n" }, { "input": "aTcodeR lANd\n", "output": "No\n" } ]
https://atcoder.jp/contests/abc358/tasks/abc358_b
Problem Statement At the entrance of AtCoder Land, there is a single ticket booth where visitors line up to purchase tickets one by one. The purchasing process takes A seconds per person. Once the person at the front of the line finishes purchasing their ticket, the next person (if any) immediately starts their purchas...
[ { "input": "3 4\n0 2 10\n", "output": "4\n8\n14\n" }, { "input": "3 3\n1 4 7\n", "output": "4\n7\n10\n" }, { "input": "10 50000\n120190 165111 196897 456895 540000 552614 561627 743796 757613 991216\n", "output": "170190\n220190\n270190\n506895\n590000\n640000\n690000\n793796\n843796...
https://atcoder.jp/contests/abc358/tasks/abc358_c
Problem Statement In AtCoder Land, there are N popcorn stands numbered 1 to N . They have M different flavors of popcorn, labeled 1, 2, \dots, M , but not every stand sells all flavors of popcorn. Takahashi has obtained information about which flavors of popcorn are sold at each stand. This information is represented b...
[ { "input": "3 5\noooxx\nxooox\nxxooo\n", "output": "2\n" }, { "input": "3 2\noo\nox\nxo\n", "output": "1\n" }, { "input": "8 6\nxxoxxo\nxxoxxx\nxoxxxx\nxxxoxx\nxxoooo\nxxxxox\nxoxxox\noxoxxo\n", "output": "3\n" } ]
https://atcoder.jp/contests/abc358/tasks/abc358_d
Problem Statement A souvenir shop at AtCoder Land sells N boxes. The boxes are numbered 1 to N , and box i has a price of A_i yen and contains A_i pieces of candy. Takahashi wants to buy M out of the N boxes and give one box each to M people named 1, 2, \ldots, M . Here, he wants to buy boxes that can satisfy the follo...
[ { "input": "4 2\n3 4 5 4\n1 4\n", "output": "7\n" }, { "input": "3 3\n1 1 1\n1000000000 1000000000 1000000000\n", "output": "-1\n" }, { "input": "7 3\n2 6 8 9 5 1 11\n3 5 7\n", "output": "19\n" } ]
https://atcoder.jp/contests/abc358/tasks/abc358_e
Problem Statement AtCoder Land sells tiles with English letters written on them. Takahashi is thinking of making a nameplate by arranging these tiles in a row. Find the number, modulo 998244353 , of strings consisting of uppercase English letters with a length between 1 and K , inclusive, that satisfy the following con...
[ { "input": "2\n2 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "output": "10\n" }, { "input": "358\n1 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n", "output": "64\n" }, { "input": "1000\n1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1000 1...
https://atcoder.jp/contests/abc358/tasks/abc358_f
Problem Statement Snuke is planning to build a maze as a new attraction in AtCoder Land. The maze is represented as a grid with N rows and M columns, with the top edge of the top-right cell being the entrance and the bottom edge of the bottom-right cell being the exit. He will create the maze by appropriately placing w...
[ { "input": "3 3 7\n", "output": "Yes\n+++++S+\n+o.o.o+\n+.+-+-+\n+o.o.o+\n+-+-+.+\n+o.o|o+\n+++++G+\n" }, { "input": "3 3 2\n", "output": "No\n" }, { "input": "4 1 4\n", "output": "Yes\n+S+\n+o+\n+.+\n+o+\n+.+\n+o+\n+.+\n+o+\n+G+\n" } ]
https://atcoder.jp/contests/abc358/tasks/abc358_g
Problem Statement AtCoder Land is represented by a grid with H rows and W columns. Let (i, j) denote the cell at the i -th row and j -th column. Takahashi starts at cell (S_i, S_j) and repeats the following action K times: He either stays in the current cell or moves to an adjacent cell. After this action, if he is in ...
[ { "input": "2 3 3\n1 2\n2 1 2\n3 4 5\n", "output": "14\n" }, { "input": "2 2 1000000000\n2 1\n100 100\n100 99\n", "output": "100000000000\n" } ]
https://atcoder.jp/contests/atcoder12live/tasks/atcoder12live_a
問題文 演奏会では N 人の演奏者が横一列に並び T 秒の曲を演奏している。 左から i (0\leq i\leq N-1) 番目の演奏者を演奏者 i と呼ぶことにする。 各演奏者について、デフォルトの音量を基準値 0 とする。指揮者は毎秒、 0\leq L\leq R\leq N-1 を満たす整数の組 (L,R) と整数 dV を選択し、 L\leq i\leq R を満たす全ての演奏者 i に、 dV だけ音量を変更するよう指示を出すことができる。 時刻 t に指示を出された演奏者は時刻 t 以降( t を含む)の音量が dV だけ変化する。 複数回音量変更の指示をした場合、変化量は累積され...
[ { "input": "5 3\n0 0 0 0 0\n0 -1 -1 -1 0\n1 2 2 2 2\n", "output": "0 0 0\n1 3 1\n1 4 -3\n" } ]
https://atcoder.jp/contests/abc357/tasks/abc357_a
Problem Statement There is a bottle of disinfectant that can disinfect exactly M hands. N aliens come one by one to disinfect their hands. The i -th alien ( 1 \leq i \leq N ) has H_i hands and wants to disinfect all of their hands once. Determine how many aliens can disinfect all of their hands. Here, even if there is ...
[ { "input": "5 10\n2 3 2 5 3\n", "output": "3\n" }, { "input": "5 10\n2 3 2 3 5\n", "output": "4\n" }, { "input": "1 5\n1\n", "output": "1\n" } ]
https://atcoder.jp/contests/abc357/tasks/abc357_b
Problem Statement You are given a string S consisting of lowercase and uppercase English letters. The length of S is odd. If the number of uppercase letters in S is greater than the number of lowercase letters, convert all lowercase letters in S to uppercase. Otherwise, convert all uppercase letters in S to lowercase.
[ { "input": "AtCoder\n", "output": "atcoder\n" }, { "input": "SunTORY\n", "output": "SUNTORY\n" }, { "input": "a\n", "output": "a\n" } ]