Submission #3558401
Source Code Expand
#include <iostream> #include <string.h> #include <stdio.h> #include <map> #include <vector> #include <math.h> #include <algorithm> #include <queue> #include <set> #include <tuple> using namespace std; #define rep(i,a) for(int i=0; i<a; i++) #define rrep(i,a) for(int i=a; i>=0; i--) #define rep1(i,a) for(int i=1; i<=a; i++) #define cout1(a) cout << a << endl; #define cout2(a,b) cout << a << " " << b << endl; #define cout3(a,b,c) cout << a << " " << b << " " << c << endl; #define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl; #define mem(a,n) memset( a, n, sizeof(a)) #define all(a) a.begin(),a.end() typedef long long ll; typedef long double ld; typedef pair<int,int> pii; typedef vector<int> V; typedef vector<V> VV; typedef vector<VV> VVV; const int INF = 1e9; const int MOD = 1e9+7; const ll LLINF = 1e18; static const double pi = 3.141592653589793; ll A, B, ans, p, q; priority_queue<ll> L; priority_queue<ll,vector<ll>,greater<ll>> R; ll topL(){return p=L.top()+A;} ll topR(){return q=R.top()+B;} int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin>>N; rep(i,N){ int l,r; cin>>l>>r; int len = r-l; B+=len; L.push(r-A); R.push(r-B); while(topL()>topR()){ ans+=p-q; L.pop(); R.pop(); L.push(q-A); R.push(p-B); } A-=len; } cout1(ans); }
Submission Info
Submission Time | |
---|---|
Task | E - NarrowRectangles |
User | mensan_fukuhara |
Language | C++14 (GCC 5.4.1) |
Score | 1000 |
Code Size | 1474 Byte |
Status | AC |
Exec Time | 45 ms |
Memory | 2036 KB |
Judge Result
Set Name | Sample | Subtask | All | ||||||
---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | 700 / 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 | AC | 1 ms | 256 KB |
1_007.txt | AC | 1 ms | 256 KB |
1_008.txt | AC | 1 ms | 256 KB |
1_009.txt | AC | 1 ms | 256 KB |
1_010.txt | AC | 1 ms | 256 KB |
1_011.txt | AC | 1 ms | 256 KB |
1_012.txt | AC | 1 ms | 256 KB |
1_013.txt | AC | 1 ms | 256 KB |
1_014.txt | AC | 1 ms | 256 KB |
1_015.txt | AC | 1 ms | 256 KB |
1_016.txt | AC | 1 ms | 256 KB |
1_017.txt | AC | 1 ms | 256 KB |
2_018.txt | AC | 33 ms | 2036 KB |
2_019.txt | AC | 31 ms | 2036 KB |
2_020.txt | AC | 24 ms | 2036 KB |
2_021.txt | AC | 37 ms | 2036 KB |
2_022.txt | AC | 37 ms | 2036 KB |
2_023.txt | AC | 37 ms | 2036 KB |
2_024.txt | AC | 37 ms | 2036 KB |
2_025.txt | AC | 37 ms | 2036 KB |
2_026.txt | AC | 37 ms | 2036 KB |
2_027.txt | AC | 37 ms | 2036 KB |
2_028.txt | AC | 37 ms | 2036 KB |
2_029.txt | AC | 37 ms | 2036 KB |
2_030.txt | AC | 37 ms | 2036 KB |
2_031.txt | AC | 45 ms | 2036 KB |
2_032.txt | AC | 45 ms | 2036 KB |
2_033.txt | AC | 45 ms | 2036 KB |
2_034.txt | AC | 45 ms | 2036 KB |
2_035.txt | AC | 34 ms | 2036 KB |
2_036.txt | AC | 29 ms | 2036 KB |