//
// main.cpp
// 11340 - Newspaper
//
// Created by Panks on 31/05/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#include <iostream>
#include <map>
#include <cstdio>
using namespace std;
int main (int argc, const char * argv[])
{
int t,in;
double answer;
char letter;
int vals;
string line;
map<char, int> values;
cin>>t;
while (t--) {
answer=0;
cin>>in;
while (in--) {
cin>>letter>>vals;
values.insert(pair<char, int>(letter, vals));
}
cin>>in;
getchar();
while (in--) {
getline(cin, line);
for (int i=0; i<line.size() ; i++) {
if (values[line[i]]) {
answer+=values[line[i]];
}
}
}
answer/=100;
printf("%.2f$\n", answer);
values.clear();
}
return 0;
}
Showing posts with label Direct Addressing Table. Show all posts
Showing posts with label Direct Addressing Table. Show all posts
Tuesday, June 5, 2012
11340 - Newspaper
Sunday, June 3, 2012
482 - Permutation Arrays
//
// main.cpp
// 482 - Permutation Arrays
//
// Created by Panks on 30/05/12.
// Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
using namespace std;
int main (int argc, const char * argv[])
{
int t, count=0;
string line1, line2;
int index;
string value;
vector<pair<int, string> > store;
cin>>t;
getchar();
while (t--) {
getchar();
count++;
getline(cin, line1);
getline(cin, line2);
stringstream ss1(line1), ss2(line2);
while (ss1>>index) {
ss2>>value;
store.push_back(pair<int, string>(index, value));
}
sort(store.begin(), store.end());
if (count>1) {
cout<<endl;
}
for (int i=0; i<store.size(); i++) {
cout<<store[i].second<<endl;
}
store.clear();
}
return 0;
}
Subscribe to:
Posts (Atom)
