记录编号 |
265383 |
评测结果 |
AAAAAAAA |
题目名称 |
三值的排序 |
最终得分 |
100 |
用户昵称 |
ConanQZ |
是否通过 |
通过 |
代码语言 |
Pascal |
运行时间 |
0.002 s |
提交时间 |
2016-06-02 18:09:15 |
内存使用 |
0.30 MiB |
显示代码纯文本
program P1123;
uses math;
var
a:array[1..1010]of longint;
i,ans,n:longint;
w:array[1..3,1..3]of longint;
num:array[1..3]of longint;
begin
//assign(input,'11.in'); reset(input);
assign(input,'sort3.in'); reset(input);
assign(output,'sort3.out'); rewrite(output);
readln(n);
for i:=1 to n do
begin
readln(a[i]);
inc(num[a[i]]);
end;
for i:=1 to num[1] do
if a[i]=2 then inc(w[1,2]) else if a[i]=3 then inc(w[1,3]);
for i:=num[1]+1 to num[1]+num[2] do
if a[i]=1 then inc(w[2,1]) else if a[i]=3 then inc(w[2,3]);
for i:=num[1]+num[2]+1 to num[1]+num[2]+num[3] do
if a[i]=1 then inc(w[3,1]) else if a[i]=2 then inc(w[3,2]);
inc(ans,min(w[1,2],w[2,1]));
dec(w[1,2],ans); dec(w[2,1],ans);
inc(ans,(w[1,2]+w[2,1])*2);
inc(ans,min(w[3,1],w[1,3]));
inc(ans,min(w[2,3],w[3,2]));
writeln(ans);
end.