Skip to content

Instantly share code, notes, and snippets.

@Eric-Bro
Created January 27, 2012 15:14
Show Gist options
  • Save Eric-Bro/1689234 to your computer and use it in GitHub Desktop.
Save Eric-Bro/1689234 to your computer and use it in GitHub Desktop.
type tagstype = array [1..5] of string;
var i,k,m, count, tags_count, max_popularity : longint;
title, tmp, site: string;
c: char;
tags: tagstype;
{ --------- }
function tagPreferred(tagname:string; alltags: tagstype; count: integer): integer;
var i: integer;
begin
for i:=1 to 5 do
if (tagname = alltags[i]) then
begin
tagPreferred:=1;
break;
end;
tagPreferred:=0;
end;
{ --------- }
begin
assign(INPUT, 'input.txt');
reset(INPUT);
assign(OUTPUT, 'output.txt');
reset(OUTPUT);
max_popularity:= 0;
tags_count:=1;
c:='';
while (c <> '#13#10') and (c <> '#13') and (c <> '#10') do
begin
read(c);
if (c = ' ') and (tags[tags_count] <> '') then
begin inc(tags_count); continue;
end;
if (c ='#13#10') or (c='#13') or (c = '#10') then break;
tags[tags_count] := tags[tags_count] + c;
end;
read(count);
for i:=1 to count do
begin
k:= 0;
tmp:= '';
readln(title);
c:='';
while (c <> '#13#10') and (c <> '#13') and (c <> '#10') do
begin
read(c);
if (c = ' ') and (tmp <> '') then
begin
k:= k + tagPreferred(tmp, tags, tags_count);
continue;
end;
if (c ='#13#10') or (c='#13') or (c = '#10') then break;
tmp:= tmp + c;
end;
if (k = tags_count) then
begin
readln(m);
if (max_popularity = 0) or (m > max_popularity) then
begin
max_popularity:=m;
site:= title;
end;
end;
end;
writeln(site);
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment