Advertisement
DASBD72

232

May 24th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.92 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <cstring>
  7. using namespace std;
  8.  
  9. int main() {
  10.     int N, M, Q;
  11.     long long point[100005]={};
  12.     char command[5];
  13.     cin >> N >> M >> Q;
  14.     vector<long long*> comment[N+1];
  15.     for(int i = 1;i <= N;i++) cin >> point[i];
  16.     for(int i = 1, x;i <= M;i++){
  17.         cin >> x;
  18.         for(int j = 1, y;j <= x;j++){
  19.             cin >> y;
  20.             comment[i].push_back(&point[y]);
  21.         }
  22.     }
  23.     for(int i = 1, x, add;i <= Q;i++){
  24.         cin >> command;
  25.         if(command[0] == 'A'){
  26.             cin >> x >> add;
  27.             for(int j = 0;j < comment[x].size();j++){
  28.                 *comment[x][j] += add;
  29.             }
  30.         }else{
  31.             cin >> x;
  32.             long long ans = 0;
  33.             for(int j = 0;j < comment[x].size();j++){
  34.                 ans += *comment[x][j];
  35.             }
  36.             cout << ans << endl;
  37.         }
  38.        
  39.     }
  40.     return 0;
  41. }
  42. /*
  43. 5 3 7
  44. 1 2 3 4 5
  45. 3 1 2 3
  46. 3 5 1 3
  47. 2 2 5
  48. QUERY 1
  49. QUERY 2
  50. QUERY 3
  51. ADD 1 10
  52. QUERY 1
  53. QUERY 2
  54. QUERY 3
  55. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement