QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#417591#8723. 乘二skip2004Compile Error//Pascal1.1kb2024-05-22 19:56:012024-05-22 19:56:02

Judging History

你现在查看的是最新测评结果

  • [2024-05-22 19:56:02]
  • 评测
  • [2024-05-22 19:56:01]
  • 提交

answer

const P = 1000000007;
var n, k, i, rem, tmp : longint;
a : array [0..200005] of longint;
ans, pw : int64;
procedure qsort(l,r:longint);
var i,j,x,y:longint;
begin
	i:=l; j:=r; x:=a[(l+r) div 2];
	repeat
		while (a[i]<x) do inc(i);
		while (a[j]>x) do dec(j);
		if (i<=j) then
		begin
			y:=a[i];
			a[i]:=a[j];
			a[j]:=y;
			inc(i);
			dec(j);
		end;
	until i>j;
	if (i<r) then qsort(i,r);
	if (j>l) then qsort(j,l);
end;
begin
	read(n, k);
	for i := 1 to n do
		read(a[i]);
	a[n + 1] := P * 2
	qsort(1, n);
	while (a[1] < P) and (k > 0) do
	begin
		tmp := a[1] * 2;
		for i := 2 to n do
		begin
			if a[i-1] > a[i] then
			begin
				writeln(-1);
				halt;
			end;
		end;

		for i := 1 to n do
		begin
			if (k = 0) or (a[i] > tmp) then
				break;
			a[i] := a[i] * 2;
			dec(k);
		end;
		qsort(1, n);
	end;
	pw := 1;
	rem := k mod n;
	k := k div n;
	while k > 30 do
	begin
		pw := (pw << 30) mod P;
		k := k - 30;
	end;
	for i := 1 to k do
		pw := pw * 2 mod P;

	for i := 1 to rem do
		ans := (ans + a[i] * pw * 2) mod P;
	for i := rem + 1 to n do
		ans := (ans + a[i] * pw) mod P;
	writeln(ans);
end.

Details

Free Pascal Compiler version 3.0.4+dfsg-23 [2019/11/25] for x86_64
Copyright (c) 1993-2017 by Florian Klaempfl and others
Target OS: Linux for x86-64
Compiling answer.code
answer.code(29,2) Fatal: Syntax error, ";" expected but "identifier QSORT" found
Fatal: Compilation aborted
Error: /usr/bin/ppcx64 returned an error exitcode