Submission #1369797
Source Code Expand
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n; priority_queue<ll> pq1; ll bias; priority_queue<ll,vector<ll>,greater<ll> > pq2; ll res; void push(ll a, ll b) { if (pq1.empty()) { pq1.push(a); pq2.push(b); return; } bias += b-a; if (a<=pq1.top()-bias) { res += pq1.top()-bias-a; pq2.push(pq1.top()-bias); pq1.pop(); pq1.push(a); pq1.push(a); } else if (a<=pq2.top()) { pq1.push(a+bias); pq2.push(a); } else { res += a-pq2.top(); pq1.push(pq2.top()+bias); pq2.pop(); pq2.push(a); pq2.push(a); } } int main() { int i; scanf("%d",&n); for (i=0;i<n;i++) { ll a, b; scanf("%lld%lld",&a,&b); push(a,b); } printf("%lld\n",res); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - NarrowRectangles |
User | tlwpdus |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 908 Byte |
Status | WA |
Exec Time | 35 ms |
Memory | 2036 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:41:19: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n); ^ ./Main.cpp:44:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%lld%lld",&a,&b); ^
Judge Result
Set Name | Sample | Subtask | All | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | 0 / 700 | ||||||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt |
Subtask | 0_000, 0_001, 0_004, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 0_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 2_018.txt, 2_019.txt, 2_020.txt, 2_021.txt, 2_022.txt, 2_023.txt, 2_024.txt, 2_025.txt, 2_026.txt, 2_027.txt, 2_028.txt, 2_029.txt, 2_030.txt, 2_031.txt, 2_032.txt, 2_033.txt, 2_034.txt, 2_035.txt, 2_036.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 1 ms | 256 KB |
0_001.txt | AC | 1 ms | 256 KB |
0_002.txt | WA | 1 ms | 256 KB |
0_003.txt | WA | 1 ms | 256 KB |
0_004.txt | AC | 1 ms | 256 KB |
1_005.txt | WA | 1 ms | 256 KB |
1_006.txt | WA | 1 ms | 256 KB |
1_007.txt | AC | 1 ms | 256 KB |
1_008.txt | WA | 1 ms | 256 KB |
1_009.txt | WA | 1 ms | 256 KB |
1_010.txt | WA | 1 ms | 256 KB |
1_011.txt | WA | 1 ms | 256 KB |
1_012.txt | WA | 1 ms | 256 KB |
1_013.txt | WA | 1 ms | 256 KB |
1_014.txt | WA | 1 ms | 256 KB |
1_015.txt | WA | 1 ms | 256 KB |
1_016.txt | WA | 1 ms | 256 KB |
1_017.txt | WA | 1 ms | 256 KB |
2_018.txt | WA | 25 ms | 2036 KB |
2_019.txt | WA | 25 ms | 2036 KB |
2_020.txt | AC | 22 ms | 2036 KB |
2_021.txt | WA | 34 ms | 2036 KB |
2_022.txt | WA | 34 ms | 2036 KB |
2_023.txt | WA | 35 ms | 1996 KB |
2_024.txt | WA | 34 ms | 2036 KB |
2_025.txt | WA | 34 ms | 1940 KB |
2_026.txt | WA | 34 ms | 2036 KB |
2_027.txt | WA | 34 ms | 2036 KB |
2_028.txt | WA | 34 ms | 2036 KB |
2_029.txt | WA | 34 ms | 2036 KB |
2_030.txt | WA | 34 ms | 2036 KB |
2_031.txt | WA | 35 ms | 1984 KB |
2_032.txt | WA | 35 ms | 1884 KB |
2_033.txt | WA | 35 ms | 1972 KB |
2_034.txt | WA | 35 ms | 1972 KB |
2_035.txt | WA | 34 ms | 2036 KB |
2_036.txt | WA | 34 ms | 2036 KB |