Problem - 1712B - Codeforces codeforces.com 유클리드 호제법이 아닌 패턴찾기 제목 Woeful Permutation 조건 time limit per test : 1 second memory limit per test : 256 megabytes input : standard input output : standard output 문제 You are given a positive integer n. Find any permutation p of length n such that the sum lcm(1,p1)+lcm(2,p2)+…+lcm(n,pn) is as large as possible. Here lcm(x,y) denotes the least common multip..
Problem - 1712A - Codeforces codeforces.com 최대 최소 Swap 제목 Wonderful Permutation 조건 time limit per test : 1 second memory limit per test : 256 megabytes input : standard input output : standard output 문제 You are given a permutation p1,p2,…,pn of length n and a positive integer k≤n. In one operation you can choose two indices i and j (1≤i> tc; while(tc--){ cin >> sz >> k; int *arr = new int[sz]; f..
Problem - 1716B - Codeforces codeforces.com 제목 Optimal Reduction 조건 time limit per test : 1 second memory limit per test : 256 megabytes input : standard input output : standard output 문제 Consider an array a of n positive integers. You may perform the following operation: select two indices l and r (1≤l≤r≤n), then decrease all elements al,al+1,…,ar by 1. Let's call f(a) the minimum number of ope..
Problem - 1716A - Codeforces codeforces.com 제목 Traveling Salesman Problem 조건 time limit per test : 1 second memory limit per test : 256 megabytes input : standard input output : standard output 문제 You are living on an infinite plane with the Cartesian coordinate system on it. In one move you can go to any of the four adjacent points (left, right, up, down). More formally, if you are standing at ..
Problem - 1716B - Codeforces codeforces.com 제목 Permutation Chain 조건 time limit per test : 2 second memory limit per test : 256 megabytes input : standard input output : standard output 문제 A permutation of length n is a sequence of integers from 1 to n such that each integer appears in it exactly once. Let the fixedness of a permutation p be the number of fixed points in it — the number of positi..
Problem - 1716A - Codeforces codeforces.com 제목 2-3 Moves 조건 time limit per test : 1 second memory limit per test : 256 megabytes input : standard input output : standard output 문제 You are standing at the point 0 on a coordinate line. Your goal is to reach the point n. In one minute, you can move by 2 or by 3 to the left or to the right (i.e., if your current coordinate is x, it can become x−3, x..
Problem - 1714E - Codeforces codeforces.com 제목 Add Modulo 10 조건 time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output 문제 You are given an array of n integers a1,a2,…,an You can apply the following operation an arbitrary number of times: select an index i (1≤i≤n) and replace the value of the element ai with the value ai+(aimod10), where aimod10 ..
Problem - 1714C - Codeforces codeforces.com 제목 Minimum Varied Number 조건 time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output 문제 Find the minimum number with the given sum of digits s such that all digits in it are distinct (i.e. all digits are unique). For example, if s=20, then the answer is 389. This is the minimum number in which all digits ..
Problem - 1714B - Codeforces codeforces.com 제목 Remove Prefix 조건 time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output 문제 Polycarp was presented with some sequence of integers a of length n (1≤ai≤n). A sequence can make Polycarp happy only if it consists of different numbers (i.e. distinct numbers). In order to make his sequence like this, Polyc..
Problem - 1714A - Codeforces codeforces.com 제목 Everyone Loves to Sleep 조건 time limit per test : 1 second memory limit per test : 256 megabytes input : standard input output : standard output 문제 Vlad, like everyone else, loves to sleep very much. Every day Vlad has to do nn things, each at a certain time. For each of these things, he has an alarm clock set, the i-th of them is triggered on hi hou..
Problem - 1213B - Codeforces codeforces.com 시간초과 문제 뒤에서 부터 제일 작은 min값을 설정하여 앞으로 검색하면서 비교 제목 Bad Prices 조건 time limit per test : 1 second memory limit per test : 256 megabytes input : standard input output : standard output 문제 Polycarp analyzes the prices of the new berPhone. At his disposal are the prices for N last days: a1,a2,…,an, where ai is the price of berPhone on the day i. Polycarp consi..