summaryrefslogtreecommitdiff
path: root/11340/newspaper.cpp
diff options
context:
space:
mode:
Diffstat (limited to '11340/newspaper.cpp')
-rw-r--r--11340/newspaper.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/11340/newspaper.cpp b/11340/newspaper.cpp
index 9ffa848..50f8d85 100644
--- a/11340/newspaper.cpp
+++ b/11340/newspaper.cpp
@@ -1,5 +1,6 @@
#include <iostream>
#include <string>
+#include <cstdio>
#include <limits>
using namespace std;
@@ -9,20 +10,21 @@ int main(){
for(int i=0; i<tc; i++){
int k, costmap[256]={0}, lines, cost;
double totcost=0;
- char c, line[10000];
-
+ unsigned char c;
+ string line;
cin>>k;
for(int j=0; j<k; j++){
- cin>>c>>cost;
- costmap[c+128] = cost;
+ scanf("%hhu", &c);
+ scanf("%i", &cost);
+ costmap[c] = cost;
}
- cin>>lines;
+ lines=cin.get();
cin.ignore();
for(int j=0; j<lines; j++){
- cin.get(line, 10000);
+ getline(cin, line);
for(int l=0; line[l]!='\n' && line[l]!='\r'; l++){
- totcost += costmap[line[l]+128];
+ totcost += costmap[line[l]];
}
}
cout.precision(2);