Submission #1820111
Source Code Expand
#include<bits/stdc++.h> using namespace std; struct duy{ long long pos, sl; }; long long n, a[100005], b[100005], res = 0; stack <duy> sdau; stack <duy> scuoi; int main(){ cin >> n; for(long long i = 1; i <= n; i++) cin >> a[i]; for(long long i = 1; i <= n; i++) cin >> b[i]; for(long long i = n; i >= 1; i--){ if(a[i] > b[i]) scuoi.push({i, a[i] - b[i]}); } for(long long i = 1; i <= n; i++){ if(a[i] > b[i]){ long long t1 = scuoi.top().pos; long long t2 = scuoi.top().sl; sdau.push({i, a[i] - b[i]}); scuoi.pop(); } else{ if(a[i] < b[i]){ long long t = b[i] - a[i]; while(t > 0){ if(scuoi.size() == 0 || (sdau.size() > 0 && abs(i - sdau.top().pos) <= abs(scuoi.top().pos - i))){ long long t1 = sdau.top().pos; long long t2 = sdau.top().sl; sdau.pop(); if(t2 >= t){ res = res + t * (i - t1); t2 = t2 - t; t = 0; if(t2 > 0) sdau.push({i, t2}); } else{ res = res + t2 * (i - t1); t = t - t2; } } else{ if(sdau.size() == 0 || (scuoi.size() > 0 && abs(i - sdau.top().pos) > abs(scuoi.top().pos - i))){ long long t1 = scuoi.top().pos; long long t2 = scuoi.top().sl; scuoi.pop(); if(t2 >= t){ res = res + t * (t1 - i); t2 = t2 - t; t = 0; if(t2 > 0) scuoi.push({i, t2}); a[t1] = b[t1] + t2; } else{ res = res + t2 * (t1 - i); t = t - t2; a[t1] = b[t1]; }} } } } else continue; } } cout << res; }
Submission Info
Submission Time | |
---|---|
Task | H - WAAAAAAAAAAAAALL |
User | vjudge1 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2334 Byte |
Status | RE |
Exec Time | 167 ms |
Memory | 2944 KB |
Judge Result
Set Name | Subtask1 | Subtask2 | All | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 30 | 0 / 30 | 0 / 140 | ||||||||||||
Status |
|
|
|
Set Name | Test Cases |
---|---|
Subtask1 | 00_00_sample.txt, 00_01_sample.txt, 00_02_sample.txt, 00_03_random.txt, 00_04_random.txt, 00_05_random.txt, 00_06_random.txt, 00_07_random.txt, 00_08_random.txt, 00_09_random.txt, 00_10_random.txt, 00_11_random.txt, 00_12_random.txt, 00_13_random.txt, 00_14_random.txt, 00_15_random.txt, 00_16_random.txt, 00_17_random.txt, 00_18_random.txt, 00_19_random.txt, 00_20_random.txt, 00_21_random.txt, 00_22_random.txt, 00_23_freedom.txt, 00_24_freedom.txt, 00_25_freedom.txt, 00_26_full.txt, 00_27_full.txt, 00_28_full.txt, 00_29_min.txt, 00_30_min.txt, 00_31_min.txt, 00_32_max.txt, 00_33_max.txt, 00_34_max.txt, 00_35_max.txt, 00_36_max.txt |
Subtask2 | 01_37_sample.txt, 01_38_sample.txt, 01_39_random.txt, 01_40_random.txt, 01_41_random.txt, 01_42_random.txt, 01_43_random.txt, 01_44_random.txt, 01_45_random.txt, 01_46_random.txt, 01_47_random.txt, 01_48_random.txt, 01_49_random.txt, 01_50_random.txt, 01_51_random.txt, 01_52_random.txt, 01_53_random.txt, 01_54_random.txt, 01_55_random.txt, 01_56_random.txt, 01_57_random.txt, 01_58_random.txt, 01_59_freedom.txt, 01_60_freedom.txt, 01_61_freedom.txt, 01_62_full.txt, 01_63_full.txt, 01_64_full.txt, 01_65_min.txt, 01_66_min.txt, 01_67_min.txt, 01_68_max.txt, 01_69_max.txt, 01_70_max.txt, 01_71_max.txt, 01_72_max.txt |
All | 00_00_sample.txt, 00_01_sample.txt, 00_02_sample.txt, 00_03_random.txt, 00_04_random.txt, 00_05_random.txt, 00_06_random.txt, 00_07_random.txt, 00_08_random.txt, 00_09_random.txt, 00_10_random.txt, 00_11_random.txt, 00_12_random.txt, 00_13_random.txt, 00_14_random.txt, 00_15_random.txt, 00_16_random.txt, 00_17_random.txt, 00_18_random.txt, 00_19_random.txt, 00_20_random.txt, 00_21_random.txt, 00_22_random.txt, 00_23_freedom.txt, 00_24_freedom.txt, 00_25_freedom.txt, 00_26_full.txt, 00_27_full.txt, 00_28_full.txt, 00_29_min.txt, 00_30_min.txt, 00_31_min.txt, 00_32_max.txt, 00_33_max.txt, 00_34_max.txt, 00_35_max.txt, 00_36_max.txt, 01_37_sample.txt, 01_38_sample.txt, 01_39_random.txt, 01_40_random.txt, 01_41_random.txt, 01_42_random.txt, 01_43_random.txt, 01_44_random.txt, 01_45_random.txt, 01_46_random.txt, 01_47_random.txt, 01_48_random.txt, 01_49_random.txt, 01_50_random.txt, 01_51_random.txt, 01_52_random.txt, 01_53_random.txt, 01_54_random.txt, 01_55_random.txt, 01_56_random.txt, 01_57_random.txt, 01_58_random.txt, 01_59_freedom.txt, 01_60_freedom.txt, 01_61_freedom.txt, 01_62_full.txt, 01_63_full.txt, 01_64_full.txt, 01_65_min.txt, 01_66_min.txt, 01_67_min.txt, 01_68_max.txt, 01_69_max.txt, 01_70_max.txt, 01_71_max.txt, 01_72_max.txt, 02_100_min.txt, 02_101_min.txt, 02_102_max.txt, 02_103_max.txt, 02_104_max.txt, 02_105_max.txt, 02_106_max.txt, 02_73_random.txt, 02_74_random.txt, 02_75_random.txt, 02_76_random.txt, 02_77_random.txt, 02_78_random.txt, 02_79_random.txt, 02_80_random.txt, 02_81_random.txt, 02_82_random.txt, 02_83_random.txt, 02_84_random.txt, 02_85_random.txt, 02_86_random.txt, 02_87_random.txt, 02_88_random.txt, 02_89_random.txt, 02_90_random.txt, 02_91_random.txt, 02_92_random.txt, 02_93_freedom.txt, 02_94_freedom.txt, 02_95_freedom.txt, 02_96_full.txt, 02_97_full.txt, 02_98_full.txt, 02_99_min.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
00_00_sample.txt | WA | 1 ms | 256 KB |
00_01_sample.txt | WA | 1 ms | 256 KB |
00_02_sample.txt | WA | 1 ms | 256 KB |
00_03_random.txt | WA | 1 ms | 256 KB |
00_04_random.txt | WA | 1 ms | 256 KB |
00_05_random.txt | WA | 1 ms | 256 KB |
00_06_random.txt | WA | 1 ms | 256 KB |
00_07_random.txt | WA | 1 ms | 256 KB |
00_08_random.txt | WA | 1 ms | 256 KB |
00_09_random.txt | WA | 1 ms | 256 KB |
00_10_random.txt | WA | 1 ms | 256 KB |
00_11_random.txt | WA | 1 ms | 256 KB |
00_12_random.txt | WA | 1 ms | 256 KB |
00_13_random.txt | WA | 1 ms | 256 KB |
00_14_random.txt | WA | 1 ms | 256 KB |
00_15_random.txt | WA | 1 ms | 256 KB |
00_16_random.txt | WA | 1 ms | 256 KB |
00_17_random.txt | WA | 1 ms | 256 KB |
00_18_random.txt | WA | 1 ms | 256 KB |
00_19_random.txt | RE | 95 ms | 256 KB |
00_20_random.txt | WA | 1 ms | 256 KB |
00_21_random.txt | WA | 1 ms | 256 KB |
00_22_random.txt | WA | 1 ms | 256 KB |
00_23_freedom.txt | WA | 1 ms | 256 KB |
00_24_freedom.txt | WA | 1 ms | 256 KB |
00_25_freedom.txt | WA | 1 ms | 256 KB |
00_26_full.txt | WA | 1 ms | 256 KB |
00_27_full.txt | RE | 96 ms | 256 KB |
00_28_full.txt | RE | 98 ms | 256 KB |
00_29_min.txt | WA | 1 ms | 256 KB |
00_30_min.txt | WA | 1 ms | 256 KB |
00_31_min.txt | WA | 1 ms | 256 KB |
00_32_max.txt | WA | 1 ms | 256 KB |
00_33_max.txt | RE | 96 ms | 256 KB |
00_34_max.txt | WA | 1 ms | 256 KB |
00_35_max.txt | RE | 97 ms | 256 KB |
00_36_max.txt | RE | 96 ms | 256 KB |
01_37_sample.txt | WA | 1 ms | 256 KB |
01_38_sample.txt | WA | 1 ms | 256 KB |
01_39_random.txt | RE | 96 ms | 256 KB |
01_40_random.txt | RE | 97 ms | 256 KB |
01_41_random.txt | WA | 2 ms | 256 KB |
01_42_random.txt | WA | 1 ms | 256 KB |
01_43_random.txt | WA | 1 ms | 256 KB |
01_44_random.txt | RE | 97 ms | 256 KB |
01_45_random.txt | WA | 1 ms | 256 KB |
01_46_random.txt | RE | 96 ms | 256 KB |
01_47_random.txt | WA | 1 ms | 256 KB |
01_48_random.txt | WA | 1 ms | 256 KB |
01_49_random.txt | RE | 96 ms | 256 KB |
01_50_random.txt | RE | 96 ms | 256 KB |
01_51_random.txt | WA | 1 ms | 256 KB |
01_52_random.txt | RE | 97 ms | 256 KB |
01_53_random.txt | WA | 2 ms | 256 KB |
01_54_random.txt | WA | 1 ms | 256 KB |
01_55_random.txt | RE | 100 ms | 256 KB |
01_56_random.txt | RE | 97 ms | 256 KB |
01_57_random.txt | RE | 97 ms | 256 KB |
01_58_random.txt | RE | 97 ms | 256 KB |
01_59_freedom.txt | WA | 1 ms | 256 KB |
01_60_freedom.txt | WA | 2 ms | 256 KB |
01_61_freedom.txt | WA | 2 ms | 256 KB |
01_62_full.txt | RE | 98 ms | 256 KB |
01_63_full.txt | RE | 96 ms | 256 KB |
01_64_full.txt | RE | 96 ms | 256 KB |
01_65_min.txt | WA | 1 ms | 256 KB |
01_66_min.txt | WA | 1 ms | 256 KB |
01_67_min.txt | WA | 1 ms | 256 KB |
01_68_max.txt | RE | 98 ms | 256 KB |
01_69_max.txt | RE | 96 ms | 256 KB |
01_70_max.txt | RE | 98 ms | 256 KB |
01_71_max.txt | WA | 2 ms | 256 KB |
01_72_max.txt | RE | 98 ms | 256 KB |
02_100_min.txt | WA | 1 ms | 256 KB |
02_101_min.txt | WA | 1 ms | 256 KB |
02_102_max.txt | RE | 164 ms | 2688 KB |
02_103_max.txt | RE | 167 ms | 2688 KB |
02_104_max.txt | RE | 164 ms | 2688 KB |
02_105_max.txt | RE | 162 ms | 2944 KB |
02_106_max.txt | RE | 164 ms | 2816 KB |
02_73_random.txt | RE | 150 ms | 2304 KB |
02_74_random.txt | RE | 160 ms | 2688 KB |
02_75_random.txt | RE | 134 ms | 1792 KB |
02_76_random.txt | RE | 153 ms | 2560 KB |
02_77_random.txt | RE | 121 ms | 1280 KB |
02_78_random.txt | RE | 145 ms | 2048 KB |
02_79_random.txt | RE | 111 ms | 768 KB |
02_80_random.txt | RE | 163 ms | 2560 KB |
02_81_random.txt | RE | 160 ms | 2816 KB |
02_82_random.txt | RE | 148 ms | 2304 KB |
02_83_random.txt | WA | 31 ms | 1536 KB |
02_84_random.txt | RE | 132 ms | 1536 KB |
02_85_random.txt | WA | 57 ms | 2944 KB |
02_86_random.txt | RE | 147 ms | 2048 KB |
02_87_random.txt | WA | 19 ms | 1152 KB |
02_88_random.txt | RE | 152 ms | 2432 KB |
02_89_random.txt | RE | 154 ms | 2560 KB |
02_90_random.txt | WA | 18 ms | 1024 KB |
02_91_random.txt | RE | 106 ms | 640 KB |
02_92_random.txt | RE | 128 ms | 1408 KB |
02_93_freedom.txt | WA | 40 ms | 2816 KB |
02_94_freedom.txt | WA | 22 ms | 1664 KB |
02_95_freedom.txt | WA | 29 ms | 2176 KB |
02_96_full.txt | RE | 102 ms | 512 KB |
02_97_full.txt | RE | 153 ms | 2304 KB |
02_98_full.txt | RE | 150 ms | 2176 KB |
02_99_min.txt | WA | 1 ms | 256 KB |