303 条题解
-
0gsrq LV 10 @ 2009-07-24 12:42:11
var
i,j,k,n:integer;
a,b,c:array[1..100] of integer;
begin
read(n);
for i:=1 to n do
read(a[i]);
for i:=1 to n do
begin
b[i]:=1;
for j :=1 to i-1 do
if (a[i]>a[j])and(b[j]+1>b[i]) then b[i]:=b[j]+1;
end;
for i := n downto 1 do
begin
c[i]:=1;
for j:=i+1 to n do
if (a[j]c[i])then c[i]:=c[j]+1;
end;
k:=0;
for i:=1 to n do
if b[i]+c[i]>k then
k:=b[i]+c[i];
write(n-k+1);
end. -
02009-07-19 14:34:23@
var i,j,k,l,m,n,max:longint;
a:array[1..100]of integer;
b1,b2:array[0..100]of integer;begin
readln(n);
for i:=1 to n do
begin
b1[i]:=1;b2[i]:=1;
end;
for i:=1 to n do read(a[i]);
for i:=n downto 1 do
for j:=n downto i+1 do
if (a[i]>a[j])and(b2[j]+1>b2[i]) then b2[i]:=b2[j]+1;for i:=1 to n do
for j:=1 to i-1 do
if (a[i]>a[j])and(b1[j]+1>b1[i]) then b1[i]:=b1[j]+1;
for i:=1 to n do
begin
if b1[i]+b2[i]>max then max:=b1[i]+b2[i];
end;
writeln(n-max+1);
end. -
02009-07-18 15:52:34@
#include
struct
{
int pre;
int value;
}
up[100]/*从左到右*/,down[100]/*从右到左*/;int height[100];
int n;void input(void)
{
int i;
scanf("%d",&n);
for(i=0;i -
02009-07-17 23:18:26@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0msvar i,n,j,max:longint; a,f,g:array[0..10000]of longint;
begin
readln(n);
for i:=1 to n do read(a[i]);
for i:=n downto 1 do
begin
f[i]:=1;
for j:=i+1 to n do
if (f[j]+1>f[i])and(a[i]>a[j]) then f[i]:=f[j]+1;
end;
// for i:=1 to n do write(f[i],' ');writeln;
for i:=1 to n do
begin
g[i]:=1;
for j:=1 to i-1 do
if (g[j]+1>g[i])and(a[i]>a[j]) then g[i]:=g[j]+1;
end;
max:=0;
for i:=1 to n do if f[i]+g[i]>max then max:=f[i]+g[i];
// for i:=1 to n do write(g[i],' '); writeln;
write(n-max+1);end.
-
02009-07-16 09:15:17@
啊啊啊啊啊啊啊
没看见要输出出去的人数
以为要输出最长人数
害我WA3次 -
02009-07-15 15:48:07@
include
int main ()
{
long n,i,j,p,max,l;
long a[105],b[105],c[105];
scanf("%d",&n);
for(i=1;i -
02009-07-13 16:52:02@
又是>和
-
02009-07-10 01:00:16@
终于过了。。
把递减的那个过程写倒了,
i=1 to n
j=i-1 to 1
写去了。。555。。 -
02009-07-09 09:46:08@
program xzx;
var a,b,c:array[1..100]of integer;
n,i,j,k:integer;
max,maxb,maxc:integer;
begin
readln(n);
for i:=1 to n do
read(a[i]);
readln;
max:=0;
for i:=1 to n-1 do
begin
for j:=1 to n do
begin
b[j]:=1;
c[j]:=1;
end;
for j:=2 to i do
begin
maxb:=0;
for k:=1 to j-1 do
if a[j]>a[k] then
if b[k]>maxb then maxb:=b[k];
b[j]:=maxb+1;
end;
for j:=i+2 to n do
begin
maxc:=0;
for k:=i+1 to j-1 do
if a[j]maxc then maxc:=c[k];
c[j]:=maxc+1;
end;
maxb:=0;
for j:=1 to i do
if b[j]>maxb then maxb:=b[j];
maxc:=0;
for j:=i+1 to n do
if c[j]>maxc then maxc:=c[j];
if maxb+maxc>max then max:=maxb+maxc;
end;
writeln(n-max);
end. -
02009-07-08 22:11:02@
50 / 110 (45%)
AC 50 纪念下
-
02009-07-07 17:22:15@
var
a,f,g:array[0..1000] of longint;
i,j,k,l,m,n,x,y,z:longint;
begin
readln(n);
for i:=1 to n do read(a[i]);for i:=n downto 1 do begin
for j:=i+1 to n do
if (a[j] -
02009-07-03 16:52:27@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms
var a,f,g,b:array [0..1148] of integer;
n,i,j,k,l,o,m:integer;
begin
fillchar(f,sizeof(f),0);
fillchar(g,sizeof(f),0);
for i:=1 to n do
read(a[i]);
for i:=n downto 1 do begin
for j:=i+1 to n do
if (f[j]>f[i]) and (a[j]g[j]) and (a[j]f[0] then f[0]:=f[i]+g[i];
writeln(n-f[0]+1);
end. -
02009-06-28 08:46:38@
program fads;
var a,s,d,c,i,m,k,f,ru:integer;
r,j:array[1..10000] of integer;
begin
readln(a);
for i:=1 to a do
r[i]:=0;for i:=1 to a do
read(r[i]);for i:=1 to a-1 do
for ru:=i+1 to a do
if r[i]>r[ru] then
begin
f:=r[i];
r[i]:=r[ru];
r[ru]:=f;
end;
i:=a;
m:=a div 2+2;
k:=a div 2+1;
d:=1;while i0 do
begin
if d=1 then
begin
j[k]:=r[i];
k:=k-1;
end
else
begin
j[m]:=r[i];
m:=m+1;
end;
d:=d+1;
if d>2 then
d:=d-2;
i:=i-1;
end;for i:=1 to a do
write(j[i],' ');
writeln;
end. -
02009-06-26 09:09:23@
典型动规拉...
var a,b,c:array[1..100] of longint;
n,i,j,max:longint;
begin
readln(n);
fillchar(a,sizeof(a),0);
for i:=1 to n do read(a[i]);
fillchar(b,sizeof(b),0);
b[1]:=1;
for i:=2 to n do
begin
b[i]:=1;
for j:=1 to i-1 do
if (a[j] -
02009-06-16 18:32:35@
var a,f,g,b:array [0..1148] of integer;
n,i,j,k,l,o,m:integer;
begin
readln(n);
fillchar(f,sizeof(f),0);
fillchar(g,sizeof(g),0);
for i:=1 to n do
read(a[i]);
for i:=n downto 1 do begin
for j:=i+1 to n do
if (f[j]>f[i]) and (a[j]g[i]) and (a[j]f[0] then f[0]:=f[i]+g[i];
writeln(n-f[0]+1);
end. -
02009-06-13 14:16:54@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms太有纪念意义了,不靠标程,自己编过……
-
02009-06-07 21:33:50@
留个纪念~~
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms给大家几个自己编的例据~
Input:
16
173 183 175 192 156 199 201 192 169 158 193 210 180 176 179 166
Output:
7 -
02009-06-03 23:13:13@
两次导弹拦截
-
02009-05-29 20:11:17@
两次 Dp+枚举
-
02009-05-27 21:18:53@
#include
using namespace std;
ifstream fin("chorus.in");
ofstream fout("chorus.out");
int main (void)
{
int n;
fin>>n;
int a[n+1],i,d[n+1],c[n+1],j,sum1=0;
for (i=1;i>a[i];
d[i]=1;
c[i]=1;
}
for (i=2;i