303 条题解
-
0wangyk LV 6 @ 2009-05-10 00:06:09
经验错误
先是看成保留多少人
错误一次
身高比较当成导弹拦截了
加上了=
又错了一次 -
02009-05-09 11:22:45@
program po;
var
s,f1,f2,a,b:array[0..50000]of longint;
i,j,k,n,max:longint;
begin
readln(n);
for i:=1 to n do read(a[i]);
k:=1;
f1[1]:=1;
s[k]:=a[1];
for i:=2 to n do begin
if s[k] -
02009-05-08 13:12:17@
左一个导弹,右一个导弹
加起来就完了
var a,b:array[0..100]of integer;
l,r:array[0..100]of integer;
i,j,k,n,s:integer;
begin readln(n);
for i:=1 to n do
read(a[i]);
readln;
for i:=1 to 100 do
l[i]:=1;
for i:=n-1 downto 1 do
for j:=i+1 to n do
if (a[i]>a[j])and(l[i]a[j])and(r[i] -
02009-05-08 08:41:20@
本问题可以分解成:
1 从前向后递推最大升序列,可以利用f[0]=0;
2 从后向前递推最大降序列,可以利用g[n+1]=0;
3 枚举所有学生以其为最高点的最大升序和最大降序之和,求最大;
4 从总数中减去,注意自身多重复一次,需要做加一减一处理. -
02009-05-07 17:43:37@
var
i,j,max,cc,n:integer;
x1,x2,h:array[1..100]of integer;
begin
readln(n);
for i:=1to n do
begin
read(h[i]);
x1[i]:=1;
x2[i]:=1;
end;
for i:=1to n do
begin
max:=0;
for j:=i-1 downto 1 do
if (h[i]>h[j])and(max -
02009-05-03 15:43:51@
var
a,f:array[0..200] of longint;
n,ans,tot,sum:longint;
procedure init;
var i:longint;
begin
readln(n);
for i:=1 to n do read(a[i]);
end;
procedure main;
var i,j,k:longint;
begin
for k:=1 to n do
begin
tot:=0;
for i:=1 to n do f[i]:=1;
for i:=k downto 1 do
for j:=i-1 downto 1 do
if (a[i]>a[j]) and (f[j] -
02009-05-02 16:23:56@
1 1 1 A CCCCCC
1 1 1 A A C C
1 1 1 A A C C
1 1 1 A A C
1 1 1 AAAAAAA C
1 1 1 A A C C
1 1 1 A A C C
1 1 1 A A CCCCCC -
02009-04-24 15:30:01@
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
水题 -
02009-04-19 17:26:33@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms
var q,f,a:array[1..1000] of integer;
min,i,j,max,k,n,m,x:integer;
begin
readln(n);min:=maxint;
for i:=1 to n do read(a[i]);
for k:=1 to n do
begin
m:=k;max:=0;
for i:=1 to n do q[i]:=1;
for i:=2 to k do
for j:=1 to i-1 do
if (a[i]max then max:=q[i];
m:=m-max;
for i:=1 to n do q[i]:=1;
x:=n-k+1;
max:=0;
for i:=n-1 downto k do
for j:=n downto i+1 do
if (a[i]max then max:=q[i];
x:=x-max;
if x+m -
02009-04-04 16:02:51@
一定要记住:
不能只找最高点
而要把每个人当作最高点试一遍!
交了两次
刚学DP,练练手 请高人给几道经典题 -
02009-03-29 21:32:11@
var a,b,c:array[1..100] of longint;
i,j,k,n,num,ml,mr,ii,jj:longint;procedure left(x2:longint);
begin
ml:=0;
for ii:=1 to x2-1 do b[ii]:=1;
for ii:=2 to x2-1 do
for jj:=1 to ii-1 do
begin
if (a[ii]a[jj]) and (b[jj]+1>b[ii]) then b[ii]:=b[jj]+1;
if b[ii]>ml then ml:=b[ii];
end;
end;procedure right(x3:longint);
begin
mr:=0;
for ii:=x3+2 to n do c[ii]:=1;
for ii:=x3+2 to n do
for jj:=x3+1 to ii-1 do
begin
if (a[ii]mr then mr:=c[ii];
end;
end;begin
readln(n);
for i:=1 to n do read(a[i]);
for i:=1 to n do
begin
left(i); right(i);
if ml+mr>num then num:=ml+mr;
end;
left(n);
writeln(n-num-1);
readln;
readln;
end. -
02009-03-28 15:23:53@
不知道怎么反过来~ 只好弄2个~
function dd(k:integer):integer;
var max,i,j:integer;
begin
max:=0;
for i:= 1 to k do f[i]:=1;
for i:= k downto 2 do
for j:= i downto 1 do
begin
if ( a[i] > a[j] ) and ( f[i] + 1 > f[j] ) then
f[j]:=f[i]+1;
if f[j] > max then max:=f[j];
end;
exit(max);
end;function bb(k:integer):integer;
var max,i,j:integer;
begin
max:=0;
for i:= k to n do f[i]:=1;
for i:= k to n-1 do
for j:= i to n do
begin
if ( a[i] > a[j] ) and ( f[i] + 1 > f[j] ) then
f[j]:=f[i]+1;
if f[j] > max then max:=f[j];
end;
exit(max);
end; -
02009-03-19 14:31:04@
编译通过...
├ 测试数据 01:答案正确... 0ms
├ 测试数据 02:答案正确... 0ms
├ 测试数据 03:答案正确... 0ms
├ 测试数据 04:答案正确... 0ms
├ 测试数据 05:答案正确... 0ms
├ 测试数据 06:答案正确... 0ms
├ 测试数据 07:答案正确... 0ms
├ 测试数据 08:答案正确... 0ms
├ 测试数据 09:答案正确... 0ms
├ 测试数据 10:答案正确... 0ms
---|---|---|---|---|---|---|---|-
Accepted 有效得分:100 有效耗时:0ms -
02009-03-15 13:00:51@
#include
int main()
{
int a[100],i,j,t=0,s=0,p=0,q=0,number;
scanf("%d",&number);
for(i=0;i=0;j--)
{
if(a[i] -
02009-03-11 17:37:45@
var
a:array[0..101,1..3]of longint;
i,j,n,max,maxn:longint;
begin
readln(n);
a[0,1]:=-maxlongint;
a[n+1,1]:=-maxlongint;
for i:=1 to n do
begin
read(a);
a:=1;
a:=1;
end;
for i:=1 to n do
begin
max:=0;
for j:=i-1 downto 0 do
if(a[j,1]max)then max:=a[j,2];
inc(a,max);
end;
for i:=n downto 1 do
begin
max:=0;
for j:=i+1 to n+1 do
if(a[j,1]max)then max:=a[j,3];
inc(a,max);
end;
maxn:=0;
for i:=1 to n do
if a+a>maxn then maxn:=a+a-1;
writeln(n-maxn);
end. -
02009-03-08 10:30:57@
var
t,f1,f2:array[1..100]of byte;
i,j,n,max:integer;begin
readln(n);
for i:=1 to n do begin
read(t[i]);f1[i]:=1;f2[i]:=1;
end;
max:=0;
for i:=2 to n do
for j:=1 to i-1 do
begin
if (t[i]>t[j])and(f1[j]>=f1[i]) then f1[i]:=f1[j]+1;
if (t[n-i+1]>t[n-j+1])and(f2[n-j+1]>=f2[n-i+1]) then
f2[n-i+1]:=f2[n-j+1]+1;
end;
for i:=1 to n do if max -
02009-02-21 14:35:57@
TXX love Horse-TANG
( 2009-1-10 20:23:50 )
-
02009-02-14 21:40:05@
呵呵,动归第一题
var
a,b,t:array[1..100] of integer;
n,i,j,ans:integer;
begin
readln(n);
ans:=0;
for i:=1 to n do read(t[i]);
a[1]:=1;
for i:=2 to n do
begin
a[i]:=0;
for j:=1 to i-1 do
if (a[j]>a[i])and(t[j]b[i])and(t[j]ans then ans:=a[i];
end;
writeln(n-ans);
end. -
02009-02-05 16:30:44@
#include
using namespace std;
int a[10000],b[10000],c[10000],i,j,k,n;
int main()
{
cin>>n;
for (i=1;i>a[i];
for (i=1;ii;j--)
if (a[j]c[i])
c[i]=c[j]+1;
}
int maxn=1;
for (i=1;imaxn)
maxn=c[i]+b[i];
cout -
02009-02-04 19:32:23@
#include
using namespace std;int p[102],a[102],b[102];
int l1[102],l2[102],n;int find(int x,int len)
{
int l,r;
l=1;r=len;
while (l=x) r=mid-1; else l=mid+1;
}
return l;
}main()
{
cin>>n;
for (int i=1;i>a[i];
memset(p,0,sizeof(p));l1[0]=0;p[1]=30000;
for (int i=1;il1[i]) {p[j+1]=30000;l1[i]+=1;}
p[j]=a[i];
}
memset(p,0,sizeof(p));l2[n+1]=0;p[1]=30000;
for (int i=n;i>=1;i--)
{
l2[i]=l2;
int j=find(a[i],l2[i]);
if (j>l2[i]) {p[j+1]=30000;l2[i]+=1;}
p[j]=a[i];
}
int m=0;
for (int i=1;im) m=l1[i]+l2[i]-1;
cout