Submission #1452679
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin >> n; ll l, r, len; ll pbl = 0, pbr = 0, ans = 0; priority_queue<ll> ql; priority_queue<ll, vector<ll>, greater<ll>> qr; while (n--) { cin >> l >> r; len = r - l; pbr += len; ql.push(r - pbl); qr.push(r - pbr); while ((L = ql.top() + pbl) > (R = pbr + qr.top())) { ans += L - R; ql.pop(); qr.pop(); ql.push(R - pbl); qr.push(L - pbr); } pbl -= len; } cout << ans << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - NarrowRectangles |
User | gabrielsimoes |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 573 Byte |
Status | CE |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:27:11: error: ‘L’ was not declared in this scope while ((L = ql.top() + pbl) > (R = pbr + qr.top())) { ^ ./Main.cpp:27:34: error: ‘R’ was not declared in this scope while ((L = ql.top() + pbl) > (R = pbr + qr.top())) { ^