Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- RosyIsh's code!
- */
- #include<iostream>
- #include <algorithm>
- #include <bitset>
- #include <cassert>
- #include <cctype>
- #include <cmath>
- #include <cstdio>
- #include <cstdlib>
- #include <cstring>
- #include <ctime>
- #include <deque>
- #include <functional>
- #include <iomanip>
- #include <iostream>
- #include <list>
- #include <map>
- #include <numeric>
- #include <queue>
- #include <set>
- #include <sstream>
- #include <stack>
- #include <string>
- #include <utility>
- #include <vector>
- #define VI vector<int>
- #define PI pair<int,int>
- #define PB(x) push_back(x)
- #define MP(x,y) make_pair(x,y)
- #define fill(a,b) memset((a),(b),sizeof((a)))
- #define MX 100003
- typedef long long LL;
- using namespace std;
- int times[MX];
- LL bit[MX];
- LL sum[MX];
- VI K;
- int n,m,k;
- int main(){
- //freopen("out.txt","w",stdout);
- //freopen("in.txt","r",stdin);
- scanf("%d %d %d",&n,&m,&k);
- for(int i=1;i<=m;i++){
- int a,b,c;
- scanf("%d %d %d",&a,&b,&c);
- int j = a;
- while(j<n+1){
- times[j]++;
- sum[j]+=c;
- bit[j]+=a;
- j += (j & -j);
- }
- j = b+1;
- while(j<n+1){
- times[j]--;
- sum[j]-=c;
- bit[j]-=a;
- j += (j & -j);
- }
- }
- LL fin = 0;
- for(int i = 0;i<k;i++){
- int x;
- scanf("%d",&x);
- LL ans = 0 , t = 0 , b = 0;
- int j = x;
- while(j>0){
- ans+=sum[j];
- t+=times[j];
- b+=bit[j];
- j -= (j & -j);
- }
- ans+=(x*t) - b;
- fin+=ans;
- }
- cout<<fin<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement