fork download
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <cmath>
  4. #include <iomanip>
  5. #include <string>
  6. #include <fstream>
  7. #include <sstream>
  8. #include <vector>
  9. #include <map>
  10.  
  11. #include <algorithm>
  12. using namespace std;
  13.  
  14.  
  15.  
  16. #define all(v) (v).begin(),(v).end()
  17. #define sz(v) ((int)((v).size()))
  18.  
  19.  
  20. typedef vector<int> vi;
  21.  
  22. int main(){
  23.  
  24.  
  25. #ifndef ONLINE_JUDGE
  26. freopen("in.txt","r",stdin);
  27. freopen("out.txt","w",stdout);
  28. #endif
  29.  
  30.  
  31. int num;
  32.  
  33.  
  34. scanf("%d",&num);
  35. vi m(num);
  36.  
  37. for(int i=0; i<num ; i++)
  38. cin>>m[i];
  39.  
  40. int shoot;
  41. cin>>shoot;
  42.  
  43. //vector<pair<int , int>> my(shoot) ;
  44. int f,s;
  45.  
  46. for(int i=0; i<shoot ; i++){
  47. cin>>f>>s;
  48. f--;
  49. if(f==0){
  50. m[f+1]+=m[f]-s;
  51. m[f]=0;
  52. }
  53.  
  54.  
  55.  
  56. else if(f == num-1){
  57. m[f-1]+=s-1;
  58. m[f]=0;
  59. }
  60. else{
  61.  
  62. m[f+1]+=m[f]-s;
  63. m[f-1]+=s-1;
  64. m[f]=0;
  65. }
  66.  
  67. }
  68.  
  69. for(int i=0; i<num ; i++)
  70. cout<<m[i]<<endl;
  71.  
  72. return 0;
  73. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
0