Problem Description dxy has a collection of a series of books called “The Stories of SDOI”,There are n(n≤19) books in this series.Every book has a number from 1 to n. dxy puts these books in a book stack with the order of their numbers increasing fro…
Reorder the Books Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 919    Accepted Submission(s): 501 Problem Description dxy has a collection of a series of books called "The Stories of SDOI&q…
http://acm.hdu.edu.cn/showproblem.php?pid=5500 Reorder the Books Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 942    Accepted Submission(s): 519 Problem Description dxy has a collection of…
Reorder the Books 问题描述 dxy家收藏了一套书,这套书叫<SDOI故事集>,<SDOI故事集>有n(n\leq 19)n(n≤19)本,每本书有一个编号,从11号到nn号. dxy把这些书按编号从小到大,从上往下摞成一摞.dxy对这套书极其重视,不允许任何人动这套书. 有一天Evensgn到dxy家玩,dxy因为和妹子有约会,就让Evensgn自己待在他家.Evensgn对这套书非常好奇,偷偷的看了一下,结果发现这里面竟然有当年小E和小Q的故事.Evensgn看…
Reorder the Books Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5500 Description dxy家收藏了一套书,这套书叫<SDOI故事集>,<SDOI故事集>有n(n≤19)n(n\leq 19)n(n≤19)本,每本书有一个编号,从111号到nnn号. dxy把这些书按编号从小到大,从上往下摞成一摞.dxy对这套书极其重视,不允许…
题意:   有一个1→n的排列形成的数列,我们要用最少的操作次数把这个数列从小到大排序,每次操作都是把一个数放到整个数列的最前面. 思路:        首先最大的数n是不用操作的(其他数操作好了,n自然在最后面了).先找到数n的位置,在n之前找n-1,若没找到n-1,则n-1需要操作,所有小于n-1的数均需要操作:若找到了n-1,再接着往前依次找n-2,n-3,...假如数k找不到了,那就是至少需要k次操作. 复杂度O(n). #pragma comment(linker, "/STACK:1…
题意: 有n本书,编号为1~n,现在书的顺序乱了,要求恢复成有序的样子,每次只能抽出其中一本并插到最前面,问最少需要多少抽几次? 思路: 如果pos[i]放的不是书i的话,则书i的右边所有的书都必须抽出来.抽出来的书必定可以回到它最终的位置上,即每本书最多抽出来1次,可以想象抽出来后直接扔掉,在剩下的书中找到一个有序,且最后一个元素为n,且等差为1的序列{...n-2,n-1,n}. //#include <bits/stdc++.h> #include <iostream> #i…
The Highest Mark 问题描述 2045年的SD省队选拔,赛制和三十年前已是完全不同.一场比赛的比赛时间有 tt 分钟,有 nn 道题目. 第 ii 道题目的初始分值为 A_i(A_i \leq 10^{6})A​i​​(A​i​​≤10​6​​) 分,之后每过一分钟这道题目的分值会减少 B_iB​i​​ 分,并且保证到比赛结束时分值不会减少为负值.比如,一个人在第 xx 分钟结束时做出了第 ii 道题目,那么他/她可以得到 A_i - B_i * xA​i​​−B​i​​∗x 分.…
http://acm.hdu.edu.cn/showproblem.php?pid=5500 Reorder the Books Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 920    Accepted Submission(s): 502 Problem Description dxy has a collection of…
Sequence  Accepts: 59  Submissions: 650  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536/65536 K (Java/Others) Problem Description \ \ \ \    Holion August will eat every thing he has found. \ \ \ \    Now there are many foods,but he does…