Submission #3591561
Source Code Expand
#include<bits/stdc++.h> #define cmin(a,b) (a>(b)?a=(b),1:0) #define cmax(a,b) (a<(b)?a=(b),1:0) #define dmin(a,b) ((a)<(b)?(a):(b)) #define dmax(a,b) ((a)>(b)?(a):(b)) namespace io { int F() { int F=1,n=0; char ch; while((ch=getchar())!='-'&&(ch<'0'||ch>'9')); ch=='-'?F=0:n=ch-'0'; while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0'; return F?n:-n; } long long G() { long long F=1,n=0; char ch; while((ch=getchar())!='-'&&(ch<'0'||ch>'9')); ch=='-'?F=0:n=ch-'0'; while((ch=getchar())>='0'&&ch<='9')n=n*10+ch-'0'; return F?n:-n; } } int R(int l,int r) { return (rand()<<15|rand())%(r-l+1)+l; } long long h[222222]; int tot; void push(long long v) { h[++tot]=v; std::push_heap(h+1,h+tot+1); } long long pop() { std::pop_heap(h+1,h+tot+1); return h[tot--]; } long long add; int main() { unsigned long long s0=0,len; long long x; int n=io::F(); { int l=io::F(),r=io::F(); push(l); push(l); len=r-l; x=0,s0=l; } for(register int i=2;i<=n;++i) { int l=io::F(),r=io::F(); long long tmp=pop()+add; tmp+=len; len=r-l; add-=len; x-=len; push(tmp-add); push(l-add); push(l-add); s0+=l-x; pop(); } std::sort(h+1,h+tot+1); for(register int i=n;i;--i) { long long tmp=h[n+1-i]+add; s0-=(tmp-x)*i; x=tmp; } printf("%lld\n",s0); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - NarrowRectangles |
User | ESpace |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1403 Byte |
Status | WA |
Exec Time | 40 ms |
Memory | 1024 KB |
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 | AC | 1 ms | 256 KB |
0_003.txt | AC | 1 ms | 256 KB |
0_004.txt | AC | 1 ms | 256 KB |
1_005.txt | AC | 1 ms | 256 KB |
1_006.txt | WA | 1 ms | 256 KB |
1_007.txt | AC | 1 ms | 256 KB |
1_008.txt | AC | 1 ms | 256 KB |
1_009.txt | WA | 1 ms | 256 KB |
1_010.txt | WA | 1 ms | 256 KB |
1_011.txt | AC | 1 ms | 256 KB |
1_012.txt | AC | 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 | AC | 34 ms | 1024 KB |
2_019.txt | WA | 33 ms | 1024 KB |
2_020.txt | AC | 32 ms | 1024 KB |
2_021.txt | WA | 39 ms | 1024 KB |
2_022.txt | WA | 39 ms | 1024 KB |
2_023.txt | WA | 39 ms | 1024 KB |
2_024.txt | WA | 39 ms | 1024 KB |
2_025.txt | WA | 39 ms | 1024 KB |
2_026.txt | WA | 39 ms | 1024 KB |
2_027.txt | WA | 39 ms | 1024 KB |
2_028.txt | WA | 39 ms | 1024 KB |
2_029.txt | WA | 39 ms | 1024 KB |
2_030.txt | WA | 39 ms | 1024 KB |
2_031.txt | WA | 40 ms | 1024 KB |
2_032.txt | WA | 40 ms | 1024 KB |
2_033.txt | WA | 40 ms | 1024 KB |
2_034.txt | WA | 40 ms | 1024 KB |
2_035.txt | AC | 39 ms | 1024 KB |
2_036.txt | AC | 38 ms | 1024 KB |