Submission #1452675
Source Code Expand
#include <bits/stdc++.h> using namespace std; int len[N]; priority_queue<long long> PQL, PQR; long long pbl, pbr; long long Ans; int main() { int n; cin >> n; for (int i = 0;i < n;i++) { scanf("%d%d", &pos[i].first, &pos[i].second); len[i] = pos[i].second - pos[i].first; } ll l, r, len; for (int i = 0;i < n;i++) { cin >> l >> r; len = r - l; pbr += len; PQL.push(r - pbl); PQR.push(pbr - r); while (true) { long long L = PQL.top() + pbl; long long R = -PQR.top() + pbr; if (L <= R) { break; } Ans += L - R; PQL.pop(), PQR.pop(); PQL.push(R - pbl), PQR.push(pbr - L); } 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 | 729 Byte |
Status | CE |
Compile Error
./Main.cpp:4:9: error: ‘N’ was not declared in this scope int len[N]; ^ ./Main.cpp: In function ‘int main()’: ./Main.cpp:16:18: error: ‘pos’ was not declared in this scope scanf("%d%d", &pos[i].first, &pos[i].second); ^ ./Main.cpp:17:3: error: ‘len’ was not declared in this scope len[i] = pos[i].second - pos[i].first; ^ ./Main.cpp:20:2: error: ‘ll’ was not declared in this scope ll l, r, len; ^ ./Main.cpp:23:10: error: ‘l’ was not declared in this scope cin >> l >> r; ^ ./Main.cpp:23:15: error: ‘r’ was not declared in this scope cin >> l >> r; ^ ./Main.cpp:24:3: error: ‘len’ was not declared in this scope len = r - l; ^