2017年10月08日普及组 蜡烛

这里写图片描述

程序:

var
n,i,j,t,k,sum:longint;
a:array[0..10000] of longint;
begin
    assign(input,'lazhu.in');
    reset(input);
    assign(output,'lazhu.out');
    rewrite(output);
    readln(n);
    for i:=1 to n do
    read(a[i]);
    for k:=1 to 100 do
    begin
        for i:=1 to n-1 do
        for j:=i+1 to n do
        if a[i]<a[j] then
        begin
            t:=a[i];a[i]:=a[j];a[j]:=t;
        end;
        sum:=0;
        for i:=1 to n do
        if a[i]<>0 then inc(sum);
        if sum<k then break;
        for i:=1 to k do
        dec(a[i]);
    end;
    writeln(k-1);
    close(input);
    close(output);
end.
posted @ 2017-10-08 20:31  银叶草  阅读(51)  评论(0编辑  收藏  举报
Live2D