Az alábbi letöltési lehetőségek közül választhatsz: (
segítség)
Típus: text/plain
Tartalmaz szöveget
Karakterkódolás: us-ascii
Méret: 3 KB
PROGRAM ShoppingPlan;
CONST
tid = 'small';
inputFile = 'D-'+tid+'-practice.in';
outputFile = 'D-'+tid+'-practice.out';
maxItems = 15;
maxStores = 50;
maxFull = (1 SHL maxItems) - 1;
infinitePrice = 1E9;
VAR
num_items, num_stores, price_of_gas: INTEGER;
item_names: ARRAY [1..maxItems] OF STRING;
item_perishable: ARRAY [1..maxItems] OF BOOLEAN;
store_x : ARRAY [0..maxStores] OF INTEGER;
store_y : ARRAY [0..maxStores] OF INTEGER;
store_prices : ARRAY [0..maxStores, 1..maxItems] OF INTEGER;
store_codes: ARRAY [0..maxStores] OF INTEGER;
FUNCTION Solve(): DOUBLE;
BEGIN
END;
FUNCTION NextToken(line: STRING; VAR pos: INTEGER): STRING;
VAR
pos0, len: INTEGER;
BEGIN
pos0:= pos;
len := Length(line);
WHILE (pos <= len) AND (line[pos] <> ' ') AND (line[pos] <> ':') DO INC(pos);
NextToken := Copy(line, pos0, pos-pos0);
INC(pos);
END;
PROCEDURE TestCase(id: INTEGER; VAR fin, fout: Text);
VAR
i, j, pos, len: INTEGER;
s, item_price, item_name: STRING;
errCode: WORD;
solution: DOUBLE;
BEGIN
ReadLn(fin, num_items, num_stores, price_of_gas);
ReadLn(fin, s);
len := Length(s);
pos := 1;
FOR i:= 1 TO num_items DO
BEGIN
item_names[i] := NextToken(s, pos);
item_perishable[i] := item_names[i][ Length(item_names[i]) ] = '!';
IF item_perishable[i] THEN item_names[i] := Copy(item_names[i], 1, Length(item_names[i])-1);
END;
FOR i := 0 TO num_stores DO
BEGIN
store_codes[i]:=0;
FOR j:= 1 TO num_items DO store_prices[i][j] := 0;
store_x[i]:= 0; store_y[i]:=0;
IF (i = 0) THEN CONTINUE;
Read(fin, store_x[i], store_y[i]);
ReadLn(fin, s);
len := Length(s);
pos := 2;
WHILE (pos <= len) DO
BEGIN
item_name := NextToken(s, pos);
item_price := NextToken(s, pos);
j := 1; WHILE (j <= num_items) AND (item_names[j] <> item_name) DO INC(j);
store_codes[i] := store_codes[i] OR ( 1 SHL (j-1) );
Val(item_price, store_prices[i][j], errCode);
END;
END;
solution:= Solve();
WriteLn('Case #',id,': ', solution:0:7);
WriteLn(fout, 'Case #',id,': ', solution:0:7);
END;
PROCEDURE Main();
VAR
fin, fout: Text;
i, N: INTEGER;
BEGIN
Assign(fin, inputFile);
Assign(fout, outputFile);
Reset(fin);
Rewrite(fout);
ReadLn(fin, N);
FOR i:= 1 TO N DO
BEGIN
TestCase(i, fin, fout);
END;
Close(fin);
Close(fout);
END;
BEGIN
Main();
END.