import java.io.*;
import java.util.*;
public class Request {
public static void main(String[] args) throws Exception {
Reader.init(System.in);
int noOfRequirements = Reader.nextInt();
int noOfProposals = Reader.nextInt();
double minPrice;
int maxProposals;
int bestOffer;
for(int k = 1; noOfRequirements > 0; k++) {
String[] proposalName = new String[noOfProposals];
double[] proposalPrice = new double[noOfProposals];
int[] metReqs = new int[noOfProposals];
for (int i = 0; i < noOfRequirements; i++) {
Reader.reader.readLine();
}
minPrice = 0;
maxProposals = -1;
bestOffer = 0;
for (int i = 0; i < noOfProposals; i++) {
proposalName[i] = Reader.reader.readLine();
proposalPrice[i] = Reader.nextDouble();
metReqs[i] = Reader.nextInt();
for (int j = 0; j < metReqs[i]; j++) {
Reader.reader.readLine();
}
if (metReqs[i] > maxProposals) {
maxProposals = metReqs[i];
minPrice = proposalPrice[i];
bestOffer = i;
} else if (metReqs[i] == maxProposals && minPrice > proposalPrice[i]) {
minPrice = proposalPrice[i];
bestOffer = i;
}
}
System.out.println("RFP #" + k);
System.out.println(proposalName[bestOffer]);
noOfRequirements = Reader.nextInt();
noOfProposals = Reader.nextInt();
if(noOfRequirements != 0) System.out.println("");
}
}
}
/** Class for buffered reading int and double values */
/** http://www.cpe.ku.ac.th/~jim/java-io.html */
class Reader {
static BufferedReader reader;
static StringTokenizer tokenizer;
/** call this method to initialize reader for InputStream */
static void init(InputStream input) {
reader = new BufferedReader(new InputStreamReader(input));
tokenizer = new StringTokenizer("");
}
/** get next word */
static String next() throws IOException {
while (!tokenizer.hasMoreTokens()) {
tokenizer = new StringTokenizer(reader.readLine());
}
return tokenizer.nextToken();
}
static int nextInt() throws IOException {
return Integer.parseInt(next());
}
static double nextDouble() throws IOException {
return Double.parseDouble(next());
}
}
15/08/2013
10141 - Request for Proposal - Java
Subscribe to:
Post Comments (Atom)
Programming is like sex:
One mistake and you have to support it for the rest of your life.