QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#114481 | #6343. Bitaro's travel | Scintilla | 0 | 276ms | 4524kb | C++14 | 1.3kb | 2023-06-22 09:51:40 | 2023-06-22 09:51:42 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i <= e; ++i)
#define drep(i, s, e) for (int i = s; i >= e; --i)
#define file(a) freopen(#a".in", "r", stdin), freopen(#a".out", "w", stdout)
#define pv(a) cout << #a << " = " << a << endl
#define pa(a, l, r) cout << #a " : "; rep(_, l, r) cout << a[_] << ' '; cout << endl
using i64 = long long;
const int inf = 0x3f3f3f3f;
const int N = 2e5 + 10;
int read() {
int x = 0, f = 1; char c = getchar();
for (; c < '0' || c > '9'; c = getchar()) if (c == '-') f = -1;
for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48;
return x * f;
}
int n, a[N];
int main() {
n = read();
rep(i, 1, n) a[i] = read() - inf / 2;
a[0] = -inf, a[n + 1] = inf;
for (int q = read(); q; -- q) {
int s = read() - inf / 2;
i64 ans = 0;
int l = upper_bound(a + 1, a + n + 1, s) - a - 1, r = l + 1;
while (l >= 1 || r <= n) {
if (s - a[l] <= a[r] - s) {
int i = lower_bound(a + 1, a + n + 1, 2 * s - a[r]) - a;
ans += s - a[i], s = a[i], l = i - 1;
}
else {
int i = upper_bound(a + 1, a + n + 1, 2 * s - a[l]) - a - 1;
ans += a[i] - s, s = a[i], r = i + 1;
}
}
printf("%lld\n", ans);
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Time Limit Exceeded
Test #1:
score: 5
Accepted
time: 1ms
memory: 3564kb
input:
2000 154914587 154914588 154914591 154914592 154914594 154914596 154914598 154914599 154914601 154914603 154914608 154914610 154914612 154914615 154914618 154914619 154914621 154914622 154914626 154914627 154914631 154914633 154914636 154914638 154914640 154914641 154914642 154914644 154914645 15491...
output:
809906250
result:
ok 1 number(s): "809906250"
Test #2:
score: 0
Accepted
time: 1ms
memory: 3624kb
input:
2000 356563033 356563037 356563039 356563041 356563043 356563045 356563048 356563050 356563051 356563052 356563054 356563055 356563057 356563060 356563061 356563062 356563065 356563067 356563069 356563074 356563076 356563077 356563079 356563080 356563082 356563085 356563086 356563090 356563091 35656...
output:
722242888
result:
ok 1 number(s): "722242888"
Test #3:
score: -5
Time Limit Exceeded
input:
2000 24477976 24477978 24477981 24477982 24477986 24477988 24477990 24477992 24477993 24477996 24477998 24477999 24478001 24478002 24478003 24478005 24478007 24478008 24478009 24478011 24478012 24478013 24478015 24478016 24478017 24478019 24478020 24478022 24478024 24478026 24478029 24478031 2447803...
output:
result:
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Wrong Answer
Test #31:
score: 0
Wrong Answer
time: 276ms
memory: 4524kb
input:
200000 9 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181...
output:
200107 -999599795 202154 346046 379455 269768 313076 381369 366120 265794 363817 348433 342292 260613 302587 332141 311760 281789 345769 366459 218270 221124 225466 313243 322095 332977 281351 224651 257342 259560 206246 231269 316285 371811 394056 382486 202443 357928 359464 357158 354417 368006 32...
result:
wrong answer 2nd numbers differ - expected: '999999991', found: '-999599795'
Subtask #4:
score: 0
Skipped
Dependency #1:
0%