Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <cstdio>
- #define task "COVERING"
- using namespace std;
- using ll = long long;
- using ld = long double;
- const int N = 1e5 + 2;
- struct Trec{
- ll w, h;
- bool operator < (const Trec& a) const{
- return w < a.w
- ||(w == a.w && h < a.h);
- }
- };
- Trec a[N];
- int n;
- ll ans(0);
- void Read(){
- cin >> n;
- for(int i = 1; i <= n; ++i){
- cin >> a[i].w >> a[i].h;
- a[i].w /= 2;
- a[i].h /= 2;
- }
- sort(a + 1, a + n + 1);
- }
- void Solve(){
- ll piv = 1;
- for(int i = n; i; --i){
- if(a[i].h < piv)
- continue;
- ans += (a[i].h - piv + 1) * a[i].w;
- piv = a[i].h + 1;
- }
- cout << ans * 4;
- }
- main(){
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0); if(fopen(task".INP", "r"))
- freopen(task".INP", "r", stdin),
- freopen(task".OUT", "w", stdout);
- Read();
- Solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment