Skip to content

Instantly share code, notes, and snippets.

@Eric-Bro
Created January 30, 2012 15:11
Show Gist options
  • Save Eric-Bro/1704891 to your computer and use it in GitHub Desktop.
Save Eric-Bro/1704891 to your computer and use it in GitHub Desktop.
Kirill's
type tagstype = array [1..5] of string;
var i,k,m, count, tags_count, max_popularity, s, sk : longint;
title, tmp, site: string;
c: char;
tags: tagstype;
function tagPreferred(tagname:string; alltags: tagstype; count: integer): integer;
var i, a: integer;
begin
a:=0;
for i:=1 to count do
if (tagname = alltags[i]) then
begin
tagPreferred:=1;
a:= 1;
break;
end;
if (a <> 1) then tagPreferred:=0;
end;
begin
assign(INPUT, 'Input.txt');
reset(INPUT);
assign(OUTPUT, 'Output.txt');
rewrite(OUTPUT);
s:=0;
sk:=0;
max_popularity:= 0;
tags_count:= 1;
while (not EOF) and (not EOLN) do
begin
read(c);
if (c= ' ') and (tags[tags_count] <> '') then
begin
inc(tags_count);
continue;
end;
tags[tags_count] := tags[tags_count] + c;
end;
readln(count);
for i:=1 to count do
begin
k:= 0;
m:= 0;
tmp:= '';
readln(title);
while (not EOF) and (not EOLN) do
begin
read(c);
if (c= ' ') then
begin
k:= k + tagPreferred(tmp, tags, tags_count);
tmp:='';
continue;
end;
tmp:= tmp + c;
end;
k:= k + tagPreferred(tmp, tags, tags_count);
readln(m);
if (k >= 1) then
begin
s:= s + m;
inc(sk);
end;
end;
writeln(s / sk);
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment