-
Notifications
You must be signed in to change notification settings - Fork 35
/
1162A - Zoning Restrictions Again.cpp
55 lines (52 loc) · 1.46 KB
/
1162A - Zoning Restrictions Again.cpp
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
#include<bits/stdc++.h>
#define endl '\n'
#define ll long long int
#define loop(i,a,b) for(ll i=a;i<=b;++i)
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define clr(x) x.clear()
#define MOD 1000000007
#define itoc(c) ((char)(((int)'0')+c))
#define vl vector<ll>
#define SZ(x) (x).size()
#define all(p) p.begin(),p.end()
#define mid(s,e) (s+(e-s)/2)
#define sv() ll t,n; scanf("%lld",&t);n=t; while(t--)
#define tcase() ll t,n; cin>>t;n=t; while(t--)
#define iscn(num) scanf("%d",&num);
#define scn(num) scanf("%lld",&num);
#define dbg(x) cout <<"( "<<#x << " = " << x << " )"<<endl
using namespace std;
const ll INF = 2e18 + 99;
typedef pair<ll,ll> Pair;
typedef vector<ll> vec;;
void FAST_IO();
////////////////////////
int main()
{
ll n,h,m;
scanf("%lld%lld%lld",&n,&h,&m);
vec spot(n+1,h);
ll total=0;
for(int i=0; i< m ; i++){
ll l,r,x;
scanf("%lld%lld%lld",&l,&r,&x);
for(ll j=l; j<=r; j++){
spot[j]=min(spot[j],x);
}
}
for(int i=1; i<=n; i++)
total+=(spot[i]*spot[i]);
printf("%lld\n",total);
return 0;
}
void FAST_IO()
{
// ios_base::sync_with_stdio(0);
//cin.tie(NULL);
//cout.tie(NULL);
//cout.setf(ios::fixed);
//cout.precision(2);
}