Submission #1320677
Source Code Expand
#include<iostream> #include<algorithm> #include<vector> #include<cassert> using namespace std; #define sz(x) (int)(x.size()) #define rep(i,a,b) for(int i=a;i<b;++i) #define pb push_back typedef long long ll; ////////////////////// int const N = 441; vector<ll> lp, rp; int l[N], r[N], n; void solve(){ cin >> n; rep(i, 0, n) cin >> l[i] >> r[i]; ll ans = 0; lp.pb(l[0]); rp.pb(l[0]); rep(i, 1, n){ ll pl = r[i-1] - l[i-1]; ll cl = r[i] - l[i]; rep(j, 0, sz(rp)) rp[j] += pl; rep(j, 0, sz(lp)) lp[j] -= cl; sort(rp.begin(), rp.end()); sort(lp.begin(), lp.end()); if(l[i] >= lp.back() && l[i] <= rp[0]){ lp.pb(l[i]); rp.pb(l[i]); }else if(l[i] >= rp[0]){ ans += (l[i] - rp[0]); ll tmp = rp[0]; lp.pb(tmp); rp.erase(rp.begin()); rp.pb(l[i]); rp.pb(l[i]); }else{ ans += (lp.back() - l[i]); ll tmp = lp.back(); lp.erase(lp.begin() + sz(lp) - 1); rp.pb(tmp); lp.pb(l[i]); lp.pb(l[i]); } int asd = 1; } cout << ans << endl; } int main(){ #ifdef _DEBUG freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | E - NarrowRectangles |
User | Filyan |
Language | C++14 (GCC 5.4.1) |
Score | 300 |
Code Size | 1196 Byte |
Status | RE |
Exec Time | 109 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | Subtask | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 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 | 5 ms | 256 KB |
1_006.txt | AC | 4 ms | 256 KB |
1_007.txt | AC | 5 ms | 256 KB |
1_008.txt | AC | 5 ms | 256 KB |
1_009.txt | AC | 5 ms | 256 KB |
1_010.txt | AC | 5 ms | 256 KB |
1_011.txt | AC | 5 ms | 256 KB |
1_012.txt | AC | 5 ms | 256 KB |
1_013.txt | AC | 5 ms | 256 KB |
1_014.txt | AC | 5 ms | 256 KB |
1_015.txt | AC | 5 ms | 256 KB |
1_016.txt | AC | 5 ms | 256 KB |
1_017.txt | AC | 5 ms | 256 KB |
2_018.txt | RE | 109 ms | 256 KB |
2_019.txt | RE | 97 ms | 256 KB |
2_020.txt | RE | 98 ms | 256 KB |
2_021.txt | RE | 99 ms | 256 KB |
2_022.txt | RE | 99 ms | 256 KB |
2_023.txt | RE | 98 ms | 256 KB |
2_024.txt | RE | 99 ms | 256 KB |
2_025.txt | RE | 99 ms | 256 KB |
2_026.txt | RE | 98 ms | 256 KB |
2_027.txt | RE | 99 ms | 256 KB |
2_028.txt | RE | 99 ms | 256 KB |
2_029.txt | RE | 98 ms | 256 KB |
2_030.txt | RE | 98 ms | 256 KB |
2_031.txt | RE | 99 ms | 256 KB |
2_032.txt | RE | 99 ms | 256 KB |
2_033.txt | RE | 99 ms | 256 KB |
2_034.txt | RE | 99 ms | 256 KB |
2_035.txt | RE | 101 ms | 256 KB |
2_036.txt | RE | 100 ms | 256 KB |