diff options
| author | Aditya Naik | 2018-05-11 11:22:25 -0400 |
|---|---|---|
| committer | Aditya Naik | 2018-05-11 11:22:25 -0400 |
| commit | b9dfd2442518bdb9060329fcf9c73812d1965f0e (patch) | |
| tree | e5e992e9ffbd6967e8785451ef10291b3d6e6e74 /11340/newspaper.cpp | |
| parent | a13e1cadcc23564bca85e4aec103d8fe9654aa56 (diff) | |
working on buddies optimization
Diffstat (limited to '11340/newspaper.cpp')
| -rw-r--r-- | 11340/newspaper.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/11340/newspaper.cpp b/11340/newspaper.cpp index 50f8d85..f5043cf 100644 --- a/11340/newspaper.cpp +++ b/11340/newspaper.cpp @@ -1,30 +1,26 @@ #include <iostream> #include <string> -#include <cstdio> -#include <limits> using namespace std; int main(){ int tc; cin>>tc; - for(int i=0; i<tc; i++){ - int k, costmap[256]={0}, lines, cost; + while(tc--){ + int k, costmap[500]={0}, lines, cost; double totcost=0; - unsigned char c; - string line; + string line, s; cin>>k; - for(int j=0; j<k; j++){ - scanf("%hhu", &c); - scanf("%i", &cost); - costmap[c] = cost; + while(k--){ + cin>>s>>cost; + costmap[int(s[0])+128]=cost; } - lines=cin.get(); + cin>>lines; cin.ignore(); - for(int j=0; j<lines; j++){ + while(lines--){ getline(cin, line); - for(int l=0; line[l]!='\n' && line[l]!='\r'; l++){ - totcost += costmap[line[l]]; + for(int l=0; l<line.length(); l++){ + totcost += costmap[line[l]+128]; } } cout.precision(2); |
