1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>
#include <cmath>
#include <cstdio>
#include <string>
#include <vector>
    #include <algorithm>
    #include<fstream>
    #include <ctime>
    using namespace std;
    
int main()
{
	ios_base::sync_with_stdio(0);
	int n;//liczba traw
	int m;//liczba koszen
	unsigned long long int pom;
	unsigned long long int suma;
	vector<unsigned long long int> szybkosc;


	vector<unsigned long long int> trawa;
	int day,cut,delta;
	int aday=1;
		cin>>n;
		cin>>m;
		for(int i=0;i<n;i++)
	{
		cin>>pom;
		szybkosc.push_back(pom);
		
	}
	for(int i=0;i<n;i++)
	{
		trawa.push_back(szybkosc.at(i));
	}
	///input data
	
	for(int i=0;i<m;i++)
	{
		cin>>day;
		cin>>cut;
	
		
		delta=day-aday;
		aday=day;		
		for(int i=0;i<n;i++)
			{
			trawa.at(i)+=delta*szybkosc.at(i);
			}

	
	
	//cut it!
	
	for(int i=0;i<n;i++)
	{
		if(trawa.at(i)>cut){suma+=trawa.at(i)-cut;trawa.at(i)=cut;}
	}
	cout<<suma<<endl;
	suma=0;
	}
	
	
	
	
return 0;
}