Kurniady Systems - Tools
Viewing Text Document
Title:
INC 2008 Final G
Owner: Andrian Kurniady
Last updated on: Tuesday, 15 July 2008
Description:
My solution for INC 2008 final problem G.
Content:
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <deque>
#include <map>
#include <set>
#include <string>
#include <math.h>
using namespace std;
typedef struct Hotel {
char rtype;
int bs;
int cap;
int avro;
int roco;
string name;
} Hotel;
char buffer[1000];
char getType(int rs){
if (rs<=35) return 'A';
if (rs<=48) return 'B';
return 'C';
}
int main(){
int ntc;
scanf("%d", &ntc);
for (int ttc=1;ttc<=ntc;ttc++){
int n,m;
scanf("%d%d", &n,&m);
vector<Hotel> hotels;
for (int i=0;i<n;i++){
int bs, rc, ar, ppr;
scanf("%d%d%d%d%s",&bs,&rc,&ar,&ppr, buffer);
Hotel temp;
temp.rtype = getType(bs);
temp.cap = rc;
temp.bs = bs;
temp.avro = ar;
temp.roco = ppr;
temp.name = buffer;
hotels.push_back(temp);
}
printf("Case #%d:\n", ttc);
for (int i=0;i<m;i++){
int pnum,macap;
scanf("%s%d%d", buffer, &pnum, &macap);
char rType = buffer[0];
pair<int,int> res = make_pair(1000000000, 1000);
string rname = "";
for (int j=0;j<n;j++){
if (hotels[j].rtype!=rType)
continue;
int ucap = min(hotels[j].cap, macap);
int ur = (pnum+ucap-1)/ucap;
if (ur>hotels[j].avro)
continue;
pair<int,int> tres = make_pair(ur*hotels[j].roco, hotels[j].bs*-1);
if (tres<res){
res = tres;
rname = hotels[j].name;
}
}
if (rname!=""){
printf("%d %s\n", res.first, rname.c_str());
} else {
puts("no-hotel");
}
}
}
return 0;
}
Please note that the document shown may be copyrighted.
Please contact the owner of this document for the details.
Valid XHTML and CSS. Powered by Ruby on Rails.