Alex_tz307

School-CCC Snack Vendor - Level 4

Oct 28th, 2020
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. ifstream fin("text.in");
  6. ofstream fout("text.out");
  7.  
  8. int main() {
  9.     string cell;
  10.     fin >> cell;
  11.     int rows = cell[0] - 'A' + 1, cols = cell[1] - '0';
  12.     if(cell.size() > 2)
  13.         cols = cols * 10 + (cell[2] - '0');
  14.     vector < vector < int > > grid(rows, vector < int >(cols));
  15.     for(int i = 0; i < rows; ++i)
  16.         for(int j = 0; j < cols; ++j)
  17.             fin >> grid[i][j];
  18.     vector < vector < int > > stock(rows, vector < int >(cols));
  19.     for(int i = 0; i < rows; ++i)
  20.         for(int j = 0; j < cols; ++j)
  21.             fin >> stock[i][j];
  22.     int T, ans = 0;
  23.     fin >> T;
  24.     while(T--) {
  25.         fin >> cell;
  26.         int row = cell[0] - 'A', col = cell[1] - '0' - 1;
  27.         if(cell.size() > 2) {
  28.             ++col;
  29.             col = col * 10 + (cell[2] - '0' - 1);
  30.         }
  31.         int price = grid[row][col];
  32.         if(stock[row][col] > 0) {
  33.             ans += price;
  34.             --stock[row][col];
  35.         }
  36.     }
  37.     fout << ans;
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment