#4 公司利润 2014-01-16 这真的是动归?怎么觉得有点贪心的心态在.时间复杂度O(N),空间复杂度O(1),轻松加愉快!唯一要注意的是ANS一开始要赋负值,因为最终答案可能是负的. ; var n,i,x,ans,last:longint; a:..] of longint; begin ans:=-maxlongint+; readln(n); to n do begin readln(x); then last:=x+last else last:=x; if last>ans t…
C. Sorting Railway Cars time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output An infinitely long railway has a train consisting of n cars, numbered from 1 to n (the numbers of all the cars are d…
题目描述 给出 N,B 和 D,要求找出 N 个由0或1组成的编码(1 <= N <= 64),每个编码有 B 位(1 <= B <= 8),使得两两编码之间至少有 D 个单位的"Hamming距离"(1 <= D <= 7)."Hamming距离"是指对于两个编码,他们二进制表示法中的不同二进制位的数目.看下面的两个编码 0x554 和 0x234(0x554和0x234分别表示两个十六进制数) 0x554 = 0101 010…
/* ID: lucien23 PROG: sort3 LANG: C++ */ #include <iostream> #include <fstream> #include <vector> #include <algorithm> using namespace std; void exchange(int nums[], int begin, int end, int N, int x); int sum = 0; int main() { ifst…
按字典序输出所有在123..n之间插入'+','-',' '结果为0的表达式.. http://train.usaco.org/usacoprob2?a=jUh88pMwCSQ&S=zerosum /* TASK:zerosum LANG:C++ */ #include<cstdio> #include<string> #include<algorithm> using namespace std; #define N 15 int n; int k[N],cn…
Transformations A square pattern of size N x N (1 <= N <= 10) black and white square tiles is transformed into another square pattern. Write a program that will recognize the minimum transformation that has been applied to the original pattern given…
欢迎参加——BestCoder周年纪念赛(高质量题目+多重奖励) DNA Sorting Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2182 Accepted Submission(s): 1062 Problem Description One measure of ``unsortedness'' in a sequenc…
Sorting Slides Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 2831 Accepted: 1076 Description Professor Clumsey is going to give an important talk this afternoon. Unfortunately, he is not a very tidy person and has put all his transpa…