本题使用贪心法.关键是考贪心策略.同一时候要求要细心,我提交的时候也WA了几次.大意题目就是怎样依照给定的规则排列一个01字符串,引用原题例如以下: C. Team time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Now it's time of Olympiads. Vanya and Egor decided to make his
B. Pasha Maximizes time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Pasha has a positive integer a without leading zeroes. Today he decided that the number is too small and he should make it
Problem A Hello World! Input: Standard Input Output: Standard Output When you first made the computer to print the sentence “Hello World!”, you felt so happy, not knowing how complex and interesting the world of programming and algorithm will turn o
题目如下,来源POJ Farmer John wants to repair a small length of the fence around the pasture. He measures the fence and finds that he needs N (1 ≤ N ≤ 20,000) planks of wood, each having some integer length Li (1 ≤ Li ≤ 50,000) units. He then purchases a si
NOI2015荷马史诗 一部<荷马史诗>中有 n 种不同的单词,从 1 到 n 进行编号.其中第 i 种单词出现的总次数为 wi.Allison 想要用 k 进制串 si 来替换第 i 种单词,使得其满足如下要求 对于任意的 1≤i,j≤n,i≠j,都有:si 不是 sj 的前缀 在 Allison 想要知道,如何选择 si,才能使替换以后得到的新的<荷马史诗>长度最小.在确保总长度最小的情况下,Allison 还想知道最长的 si 的最短长度是多少? 输入文件的第 1 行包含 2
给定长度为N(1≤N≤2000)的字符串S,要构造一个长度为N的字符串T.期初,T是一个空串,随后反复进行下列任意操作. ·从S的头部删除一个字符,加到T的尾部 ·从S的尾部删除一个字符,加到T的尾部 目标是要构造字典序尽可能小的字符串 提示Input · Line 1: 一个整数(integer): N· Lines 2~N +1: Line i+1 contains a single initial ('A'..'Z') of the string in the ith position i
We would like to place n rooks, ≤ n ≤ , on a n × n board subject to the following restrictions • The i-th rook can only be placed within the rectangle given by its left-upper corner (xli, yli) and its rightlower corner (xri, yri), ≤ i ≤ n, ≤ yli ≤ yr
Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one and sell one share of the stock multiple times). Ho