原题poj 2299:http://poj.org/problem?id=2299 题意,给你一个数组,去统计它们的逆序数,由于题目中说道数组最长可达五十万,那么O(n^2)的排序算法就不要再想了,归并排序~~~ 这里列出归并的解法: #include"iostream" using namespace std; const int maxn=500000+10; int T[maxn]; int a[maxn]; long long sum; void merge_sort(int…
Description There are N<tex2html_verbatim_mark> marbles, which are labeled 1, 2,..., N<tex2html_verbatim_mark> . The N<tex2html_verbatim_mark> marbles are put in a circular track in an arbitrary order. In the top part of the track ther…
A permutation on the integers from 1 to n is, simply put, a particular rearrangement of these integers. Your task is to generate a given permutation from the initial arrangement 1, 2, 3, . . . , n using only two simple operations. • Operation 1: You…
Description Shaass has n books. He wants to make a bookshelf for all his books. He wants the bookshelf's dimensions to be as small as possible. The thickness of the i-th book is ti and its pages' width is equal to wi. The thickness of each book is ei…
Description John Doe is a famous DJ and, therefore, has the problem of optimizing the placement of songs on his tapes. For a given tape and for each song on that tape John knows the length of the song and the frequency of playing that song. His pro…
Description The SUM problem can be formulated as follows: given four lists A, B, C, D<tex2html_verbatim_mark> of integer values, compute how many quadruplet (a, b, c, d ) AxBxCxD<tex2html_verbatim_mark> are such that a + b + c + d = 0<tex…
Description Most financial institutions had become insolvent during financial crisis and went bankrupt or were bought by larger institutions, usually by banks. By the end of financial crisis of all the financial institutions only two banks still co…
G - 贪心 Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Description Simon and Garfunkel Corporation (SG Corp.) is a large steel-making company with thousand of customers. Keeping the customer satisfied is one of…
Description A set of n<tex2html_verbatim_mark> 1-dimensional items have to be packed in identical bins. All bins have exactly the same length l<tex2html_verbatim_mark> and each item i<tex2html_verbatim_mark> has length lil<tex2html_…
Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 6639 Accepted Submission(s): 2514 Problem Description My birthday is coming up and traditionally I'm serving pie. Not just one pie, no, I have…
---恢复内容开始--- Description Before the invention of book-printing, it was very hard to make a copy of a book. All the contents had to be re-written by hand by so calledscribers. The scriber had been given a book and after several months he finished it…
的确,正如偶像Bruce Eckel所说,"Life is short, you need Python"! 如果你正在考虑学Java还是Python的话,那就别想了,选Python吧,你的人生会有更多的时间做其他有意思的事情. 研究生之前我没学python是有原因的:首先,我怕蛇,很怕很怕,而这货的logo竟然就是蛇,我因故而避之:其次,我不喜欢脚本语言,我会shell,但是写的时候不是很爽,只是在处理些文件操作或者字符串操作的时候才会想起它,听说python脚本神马的,我便又避之.…