关于上次射击题目100分解法(pascal)
来源:互联网 发布:mac系统怎么装ps 编辑:程序博客网 时间:2024/05/17 19:14
var
a:array[1..1000] of longint;
n,m,max,i,j,mm,t:longint;
p:boolean;
procedure qsort(l,r:longint);
var
i,j,mid,t:longint;
begin
i:=l;
j:=r;
mid:=a[i];
repeat
while a[i]>mid do inc(i);
while mid>a[j] do dec(j);
if i<=j then
begin
t:=a[i];
a[i]:=a[j];
a[j]:=t;
inc(i);
dec(j);
end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
assign(input,'dart.in');reset(input);
assign(output,'dart.out');rewrite(output);
readln(n,m);
for i:=1 to n do
readln(a[i]);
qsort(1,n);
p:=true;
repeat
mm:=max;
for i:=1 to n do
if ((max+a[i])<=m)and(t<4) then
begin
max:=max+a[i];
inc(t);
break;
end;
if mm=max then break;
until p=false;
writeln(max);
close(input);
close(output);
end.
a:array[1..1000] of longint;
n,m,max,i,j,mm,t:longint;
p:boolean;
procedure qsort(l,r:longint);
var
i,j,mid,t:longint;
begin
i:=l;
j:=r;
mid:=a[i];
repeat
while a[i]>mid do inc(i);
while mid>a[j] do dec(j);
if i<=j then
begin
t:=a[i];
a[i]:=a[j];
a[j]:=t;
inc(i);
dec(j);
end;
until i>j;
if l<j then qsort(l,j);
if i<r then qsort(i,r);
end;
begin
assign(input,'dart.in');reset(input);
assign(output,'dart.out');rewrite(output);
readln(n,m);
for i:=1 to n do
readln(a[i]);
qsort(1,n);
p:=true;
repeat
mm:=max;
for i:=1 to n do
if ((max+a[i])<=m)and(t<4) then
begin
max:=max+a[i];
inc(t);
break;
end;
if mm=max then break;
until p=false;
writeln(max);
close(input);
close(output);
end.
0 0
- 关于上次射击题目100分解法(pascal)
- 关于上次石子游戏题目100分解法(pascal)
- 关于上次公共子串题目100分解法(pascal)
- 关于上次抓猫题目100分解法(pascal)
- 关于一道题目解法
- 关于hellboundhackers的一些题目的解法
- 上次题目的答案
- 关于微软面试100题系列中两道题目的个人解法
- 上次题目的论坛版
- PAT上面一道关于“月饼”的题目的解法
- Cholesky分解法
- Crout分解法
- cholesky分解法
- Cholesky分解法
- Cholesky分解法
- 整数因子分解法
- Radar题目及解法
- 贴吧题目 解法
- 验证码的前世今生(前世篇)
- Allegro 铺铜
- Android程序员面试
- IOS pop至指定页面 --- IOS isKindOfClass 和 isMemberOfClass 的区别
- Android DiskLruCache完全解析,硬盘缓存的最佳方案
- 关于上次射击题目100分解法(pascal)
- abort函数
- Android 高仿 频道管理----网易、今日头条、腾讯视频 (可以拖动的GridView)附源码DEMO
- php 开源框架lazyphp
- 看医疗行业如何建立信息化战略决策
- 验证码的前世今生(今生篇)
- Centos7.1 安装测试Alluxio 出现Pseudo-terminal will not be allocated because stdin is not a terminal 错误的解决
- 安装python,python下的机器学习包
- 安全的等待线程结束