QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#834119 | #9517. 分道扬镳 | ningago | 100 ✓ | 3070ms | 6068kb | C++14 | 5.5kb | 2024-12-27 11:30:02 | 2024-12-27 11:30:03 |
Judging History
answer
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cctype>
namespace uvu
{
#define LOCAL ____________DONT_DEFINE_ME____________
// #define ll long long
// #define inf 0x3f3f3f3f
#define int long long
#define inf 0x3f3f3f3f3f3f3f3fll
#define infll 0x3f3f3f3f3f3f3f3fll
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define gline debug("now is #%d\n", __LINE__)
#define pii std::pair <int, int>
#define mkp std::make_pair
#define fi first
#define se second
char _ST_;
const int BUFSIZE = (1 << 2);
char ibuf[BUFSIZE], *iS = ibuf, *iT = ibuf;
char obuf[BUFSIZE], *oS = obuf, *oT = obuf + BUFSIZE;
char getc()
{
#ifdef LOCAL
return getchar();
#else
if(iS == iT) iT = (iS = ibuf) + fread(ibuf, 1, BUFSIZE, stdin);
return iS == iT ? EOF : *iS++;
#endif
#define getchar ERR
}
void Flush() { fwrite(obuf, 1, oS - obuf, stdout); oS = obuf; }
struct Flusher { ~Flusher(){ Flush(); } }iamflusher;
void putc(char c)
{
#ifdef LOCAL
putchar(c);
#else
*oS++ = c;
if(oS == oT) Flush();
#endif
#define putchar ERR
}
template <typename T = int> T read()
{
T x = 0, f = 1; char c = getc();
for(; !isdigit(c); c = getc()) if(c == '-') f = -1;
for(; isdigit(c); c = getc()) x = (x << 3) + (x << 1) + (c ^ 48);
return x * f;
}
template <typename T> void print(T x, char c)
{
static int sta[BUFSIZE], top;
top = 0;
if(x < 0) putc('-'), x = -x;
if(!x) sta[top = 1] = 0;
for(; x; x /= 10) sta[++top] = x % 10;
for(; top; ) putc(sta[top--] ^ 48);
if(c) putc(c);
}
int readstr(char *s, int base)
{
int idx = base - 1; char c = getc();
for(; !(isdigit(c) || isalpha(c) || c == '#' || c == '.'); c = getc());
for(; isdigit(c) || isalpha(c) || c == '#' || c == '.' ; c = getc()) s[++idx] = c;
return idx - base + 1;
}
void printf(const char *s) { for(; *s; s++) putc(*s); }
template <typename T, typename ... Args>
void printf(const char *s, T x, Args ... rest)
{
for(; *s; s++)
{
if(*s != '%') { putc(*s); continue; }
s++; if(*s == 'd') print(x, 0);
else if(*s == 'c') putc(x);
printf(s + 1, rest ...);
return;
}
}
template <typename T> void ckmax(T &x, T y) { x = x > y ? x : y; }
template <typename T> void ckmin(T &x, T y) { x = x < y ? x : y; }
#define mod 998244353
// #define mod 1000000007
int sm(int x) { return x >= mod ? x - mod : x; }
void plus_(int &x, int y) { x = sm(x + y); }
void mul_(int &x, int y) { x = 1ll * x * y % mod; }
int ksm(int a, int b) { int res = 1; for(; b; b >>= 1, mul_(a, a)) if(b & 1) mul_(res, a); return res; }
#define N 10010
int n, m, K;
int w_[N], _w[N];
signed v_[N], _v[N];
int p[N];
int sta[N], top, d;
int R[N], L[N];
signed dp[2][N][21];
int op;
void solve()
{
// memset(h, idx = -1, sizeof(h));
n = read(), m = read(), K = read();
for(int i = 1; i <= n; i++) _v[i] = read(), _w[i] = read();
std::iota(p + 1, p + 1 + n, 1); std::sort(p + 1, p + 1 + n, [&](int x, int y) -> bool { return 1ll * _w[x] * _v[y] > 1ll * _w[y] * _v[x]; });
for(int i = 1; i <= n; i++) v_[i] = _v[p[i]], w_[i] = _w[p[i]];
d = *std::max_element(v_ + 1, v_ + 1 + n);
{
int tot = 0, sum = 0;
for(int i = 1; i <= n; i++)
{
for(int j = std::max(m - d, tot); j <= std::min(m + d, tot + v_[i]); j++)
{
// L[j - (m - d)] = sum;
// R[j - (m - d)] = sum + w_[i];
R[j - (m - d)] = sum + (j - tot) * w_[i] / v_[i];
L[j - (m - d)] = R[j - (m - d)] - K;
// printf("L[%d] = %d, R[%d] = %d (i = %d)\n", j, L[j - (m - d)], j, R[j - (m - d)], i);
}
tot += v_[i], sum += w_[i];
}
}
int p = 0, tot = 0, sum = 0;
for(; p < n && tot < m - d; ++p, tot += v_[p], sum += w_[p]);
if(p == n) { print(sum, '\n'); return; }
dp[op = 0][tot - (m - d)][sum - L[tot - (m - d)]] = p + 1;
// for(int i = 1; i <= n; i++) printf("[%d %d] ", v_[i], w_[i]); putc('\n');
// printf("p = %d, tot = %d, sum = %d (m = %d, d = %d)\n", p, tot, sum, m, d);
int i, x, y, k;
for(i = p + 1; i <= n; i++)
{
op ^= 1;
for(x = m - d; x <= m + d; x++) for(y = L[x - (m - d)]; y <= R[x - (m - d)]; y++) if(dp[op ^ 1][x - (m - d)][y - L[x - (m - d)]])
ckmax(dp[op][x - (m - d)][y - L[x - (m - d)]], dp[op ^ 1][x - (m - d)][y - L[x - (m - d)]]);
for(x = m - d; x <= m; x++) for(y = L[x - (m - d)]; y <= R[x - (m - d)]; y++)
if(dp[op ^ 1][x - (m - d)][y - L[x - (m - d)]] && L[x + v_[i] - (m - d)] <= y + w_[i] && y + w_[i] <= R[x + v_[i] - (m - d)])
ckmax(dp[op][x + v_[i] - (m - d)][y + w_[i] - L[x + v_[i] - (m - d)]], dp[op ^ 1][x - (m - d)][y - L[x - (m - d)]]);
for(x = m + d; x >= m; x--) for(y = L[x - (m - d)]; y <= R[x - (m - d)]; y++)
{
for(k = std::max(1, dp[op ^ 1][x - (m - d)][y - L[x - (m - d)]]); k < dp[op][x - (m - d)][y - L[x - (m - d)]]; k++)
{
if(x >= v_[k] && L[x - v_[k] - (m - d)] <= y - w_[k] && y - w_[k] <= R[x - v_[k] - (m - d)])
ckmax(dp[op][x - v_[k] - (m - d)][y - w_[k] - L[x - v_[k] - (m - d)]], (signed)k);
}
}
for(x = m - d; x <= m + d; x++) for(y = L[x - (m - d)]; y <= R[x - (m - d)]; y++) dp[op ^ 1][x - (m - d)][y - L[x - (m - d)]] = 0;
}
int ans = 0;
for(x = m - d; x <= m; x++) for(y = L[x - (m - d)]; y <= R[x - (m - d)]; y++) if(dp[op][x - (m - d)][y - L[x - (m - d)]])
ckmax(ans, y);
print(ans, '\n');
}
void init()
{
}
char _ED_;
void mian()
{
debug("%.3f MB\n", abs(&_ST_ - &_ED_) / 1024.0 / 1024);
init();
for(int T = 1; T; solve(), T--);
}
#ifdef int
#undef int
#endif
}
int main()
{
// freopen("tmp.in", "r", stdin);
// freopen("tmp.out", "w", stdout);
uvu::mian(); return 0;
}
详细
Subtask #1:
score: 5
Accepted
Test #1:
score: 5
Accepted
time: 1ms
memory: 3912kb
input:
8 20 6 10 6 9 8 6 3 2 5 6 8 3 8 1 9 4 2
output:
33
result:
ok single line: '33'
Test #2:
score: 5
Accepted
time: 49ms
memory: 4316kb
input:
1000 100000 19 102 411 563 996 644 527 701 103 624 679 111 776 609 406 833 730 900 782 162 325 127 737 554 130 951 916 825 216 842 583 671 802 118 686 346 903 464 699 179 225 686 809 520 342 54 242 628 474 700 867 875 75 784 395 583 636 806 927 685 747 796 137 256 906 279 196 877 409 134 330 430 426...
output:
257302
result:
ok single line: '257302'
Test #3:
score: 5
Accepted
time: 45ms
memory: 4248kb
input:
1000 100000 20 628 3017 210 7605 315 4289 69 3839 19 5801 771 9125 215 4967 506 1014 518 7042 229 9925 581 5784 712 6952 731 9305 278 3818 956 1161 508 5529 671 8530 403 6201 376 9056 753 3327 622 5651 984 6022 742 1824 934 4078 318 2337 452 4024 819 352 888 2619 916 5616 522 8370 116 4964 498 9244 ...
output:
2479154
result:
ok single line: '2479154'
Test #4:
score: 5
Accepted
time: 1ms
memory: 3972kb
input:
1000 100000 20 34 655226588 121 758461406 151 193773058 90 260979391 13 489294543 168 270280518 183 104213478 119 711386289 108 913666750 15 536469584 183 422029348 173 651446281 141 834434742 2 473849559 34 782725992 155 244240710 156 303553027 71 832849401 78 843207585 45 332524581 15 107430195 83...
output:
499407708920
result:
ok single line: '499407708920'
Test #5:
score: 5
Accepted
time: 0ms
memory: 3924kb
input:
200 100000 13 777 709003996733 405 307773366007 955 802392553356 473 594320807294 341 914608275868 959 662164090296 409 666815154588 544 266522936125 360 909809350193 747 990373379678 107 690030141939 497 284659562140 654 265787041265 872 54203467054 831 44889678889 801 671024895872 539 213080429073...
output:
102153517297870
result:
ok single line: '102153517297870'
Test #6:
score: 5
Accepted
time: 69ms
memory: 4168kb
input:
1000 100000 20 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 ...
output:
100000000000000
result:
ok single line: '100000000000000'
Test #7:
score: 5
Accepted
time: 68ms
memory: 4384kb
input:
1000 99001 20 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 1000 20000 ...
output:
1980000
result:
ok single line: '1980000'
Test #8:
score: 5
Accepted
time: 10ms
memory: 4248kb
input:
1000 100000 2 42 86298 39 23912 497 51564 207 79276 889 14692 68 70393 397 80980 226 49518 342 48199 268 62301 863 50201 968 91180 607 35707 622 1591 930 10001 60 26604 728 42323 701 94029 685 12367 461 86450 543 40805 599 7556 916 9610 639 53187 673 16006 465 67042 395 66870 160 17989 842 35338 55 ...
output:
24501937
result:
ok single line: '24501937'
Subtask #2:
score: 5
Accepted
Dependency #1:
100%
Accepted
Test #9:
score: 5
Accepted
time: 29ms
memory: 4320kb
input:
1000 200000 12 283 931 40 88 778 938 754 814 88 967 427 117 963 731 387 692 667 167 822 145 528 491 386 420 393 752 524 946 46 270 620 906 735 983 932 683 610 538 493 677 617 777 137 59 562 323 914 823 5 395 946 94 874 95 961 360 688 265 827 33 943 210 999 443 999 618 305 418 343 241 200 990 223 450...
output:
356309
result:
ok single line: '356309'
Test #10:
score: 5
Accepted
time: 15ms
memory: 4248kb
input:
1000 500000 5 1000 628 1000 766 1000 875 1000 880 1000 315 1000 966 1000 522 1000 865 1000 343 1000 874 1000 560 1000 505 1000 453 1000 127 1000 50 1000 564 1000 353 1000 898 1000 630 1000 655 1000 425 1000 591 1000 383 1000 456 1000 738 1000 85 1000 164 1000 228 1000 224 1000 40 1000 425 1000 263 1...
output:
371113
result:
ok single line: '371113'
Test #11:
score: 5
Accepted
time: 40ms
memory: 4304kb
input:
1000 500000 20 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 ...
output:
500000000000000
result:
ok single line: '500000000000000'
Test #12:
score: 5
Accepted
time: 6ms
memory: 4264kb
input:
1000 900000 20 1000 12 997 141 992 77 999 43 998 858502226868 998 56 991 4 995 721970279096 990 62 999 14 996 225 994 49725652781 999 73288716248 991 122 997 24 999 1 990 98 991 133 994 28 990 226 992 112 994 18 998 158 990 550073266387 997 967512829193 995 139 993 457632583347 995 213 993 275063902...
output:
246906254780795
result:
ok single line: '246906254780795'
Test #13:
score: 5
Accepted
time: 0ms
memory: 3796kb
input:
1000 1000000000 20 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000000 1000 1000000000...
output:
1000000000000000
result:
ok single line: '1000000000000000'
Test #14:
score: 5
Accepted
time: 43ms
memory: 4320kb
input:
1000 400000 18 994 8840 998 105 995 8640 994 8851 997 6211 990 9732 1000 2351 993 4102 995 1481 996 9431 998 759 998 4953 996 199 999 2352 991 5350 994 55 1000 9562 1000 4475 993 8969 990 4942 994 3311 992 6485 993 5980 994 6891 994 4868 994 268 999 5981 993 9354 997 116 993 2892 997 4569 995 4474 9...
output:
3266432
result:
ok single line: '3266432'
Test #15:
score: 5
Accepted
time: 28ms
memory: 4304kb
input:
1000 600000 17 998 92099 999 51283 998 98428 992 8640 1000 67120 997 37177 995 54430 993 31942 992 86296 995 55237 995 33892 995 57412 1000 44030 994 69258 992 20404 998 69871 996 30312 993 19263 995 65618 998 57755 996 76892 991 46263 995 83300 994 69725 990 91901 993 69193 995 29518 992 43404 995 ...
output:
41613583
result:
ok single line: '41613583'
Subtask #3:
score: 10
Accepted
Test #16:
score: 10
Accepted
time: 1ms
memory: 4140kb
input:
10000 1000000000 20 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 333 ...
output:
3330000
result:
ok single line: '3330000'
Test #17:
score: 10
Accepted
time: 113ms
memory: 4288kb
input:
10000 1000000 17 81 35 156 307 170 333 47 16 9 108 299 171 106 75 319 310 32 251 202 39 146 294 214 145 173 241 299 203 285 92 196 251 166 257 75 218 153 278 99 104 5 131 118 185 253 177 49 183 261 311 1 123 200 254 327 232 225 142 111 266 235 276 96 82 321 297 69 46 226 14 44 313 193 130 298 135 38...
output:
1455996
result:
ok single line: '1455996'
Test #18:
score: 10
Accepted
time: 0ms
memory: 5936kb
input:
10000 2000000 17 1 310 21 2 193 216 171 144 60 283 319 204 313 203 325 142 236 276 185 181 292 27 70 261 31 289 9 243 133 235 176 62 181 255 44 75 91 38 13 223 122 318 223 94 280 298 122 150 244 184 126 108 250 321 141 161 23 289 171 109 24 181 136 209 90 3 298 165 13 3 234 132 207 159 315 41 54 199...
output:
1664523
result:
ok single line: '1664523'
Test #19:
score: 10
Accepted
time: 47ms
memory: 4332kb
input:
10000 1500000 3 317 174 303 333 316 19 300 197 317 288 306 39 313 73 329 246 322 74 319 330 329 59 321 122 323 9 322 83 302 151 301 324 313 212 328 261 315 253 321 117 304 60 304 9 329 296 320 259 306 59 310 28 302 77 327 271 324 233 316 164 322 23 320 158 328 297 329 265 310 174 329 256 332 288 301...
output:
1206110
result:
ok single line: '1206110'
Test #20:
score: 10
Accepted
time: 217ms
memory: 4260kb
input:
10000 1000000 20 317 71 320 145 321 76 315 3 329 139 331 149 305 78 311 194 312 90 322 37 320 5 319 58 331 240 314 294 332 288 315 319 331 319 331 193 300 189 325 327 326 201 300 116 300 252 303 207 306 306 307 317 300 162 309 91 331 289 321 242 301 62 329 332 312 228 325 208 312 214 315 50 306 210 ...
output:
882383
result:
ok single line: '882383'
Test #21:
score: 10
Accepted
time: 73ms
memory: 4312kb
input:
10000 2000000 10 332 178 328 139 308 283 313 297 303 36 320 197 333 217 311 136 322 221 306 193 318 48 318 39 305 108 309 77 311 289 319 183 317 66 311 243 320 221 301 52 321 259 330 75 313 261 305 229 308 267 326 243 327 159 304 309 309 74 333 79 322 10 308 222 318 49 307 333 320 70 320 186 300 130...
output:
1437404
result:
ok single line: '1437404'
Test #22:
score: 10
Accepted
time: 111ms
memory: 4252kb
input:
10000 1500000 12 308 90 303 270 301 95 311 195 319 271 318 262 317 230 311 48 317 152 302 29 330 306 307 104 327 99 329 240 306 112 322 4 321 37 321 116 329 50 319 201 332 11 320 104 327 143 327 307 305 165 310 329 303 325 313 321 326 324 319 326 300 311 329 25 311 332 333 331 331 148 326 176 308 64...
output:
1214559
result:
ok single line: '1214559'
Subtask #4:
score: 20
Accepted
Test #23:
score: 20
Accepted
time: 193ms
memory: 5004kb
input:
10000 4778421 1 963 963 431 431 128 128 1961 1961 1522 1522 631 631 1667 1667 1095 1095 488 488 511 511 946 946 729 729 582 582 672 672 636 636 1301 1301 582 582 1640 1640 57 57 985 985 331 331 1997 1997 1202 1202 1360 1360 1727 1727 59 59 51 51 1873 1873 1124 1124 844 844 864 864 612 612 1163 1163 ...
output:
4778421
result:
ok single line: '4778421'
Test #24:
score: 20
Accepted
time: 1ms
memory: 4188kb
input:
10000 1000000000 1 2000 1000000000000 2000 1000000000000 2000 1000000000000 2000 1000000000000 2000 1000000000000 2000 1000000000000 2000 1000000000000 2000 1000000000000 2000 1000000000000 2000 1000000000000 2000 1000000000000 2000 1000000000000 2000 1000000000000 2000 1000000000000 2000 1000000000...
output:
10000000000000000
result:
ok single line: '10000000000000000'
Test #25:
score: 20
Accepted
time: 116ms
memory: 4580kb
input:
10000 1748346 1 334 334000000000 112 112000000000 117 117000000000 802 802000000000 562 562000000000 400 400000000000 53 53000000000 567 567000000000 894 894000000000 13 13000000000 431 431000000000 902 902000000000 77 77000000000 734 734000000000 564 564000000000 440 440000000000 815 815000000000 7...
output:
1748346000000000
result:
ok single line: '1748346000000000'
Test #26:
score: 20
Accepted
time: 2ms
memory: 4148kb
input:
10000 998244353 1 211 775674032281 727 743808676719 923 632948588419 388 271816761368 245 468272038577 420 396364861924 624 269922023795 801 453004044188 905 347067355055 35 119195062753 497 983486581856 387 927605254567 717 449026220050 840 804547700404 76 153294721896 261 652749436454 949 48671819...
output:
5026905569512133
result:
ok single line: '5026905569512133'
Test #27:
score: 20
Accepted
time: 39ms
memory: 4544kb
input:
10000 9776140 1 998 998 999 999 997 997 1000 1000 1000 1000 997 997 995 995 1000 1000 998 998 997 997 1000 1000 995 995 995 995 998 998 1000 1000 997 997 1000 1000 997 997 997 997 999 999 995 995 999 999 1000 1000 995 995 999 999 998 998 1000 1000 996 996 997 997 998 998 996 996 995 995 995 995 1000...
output:
9776139
result:
ok single line: '9776139'
Test #28:
score: 20
Accepted
time: 248ms
memory: 4860kb
input:
10000 2575197 1 78 39000000000 188 94000000000 1242 621000000000 758 379000000000 1882 941000000000 658 329000000000 74 37000000000 638 319000000000 830 415000000000 418 209000000000 946 473000000000 704 352000000000 218 109000000000 1044 522000000000 1834 917000000000 826 413000000000 1638 81900000...
output:
1287598499999999
result:
ok single line: '1287598499999999'
Test #29:
score: 20
Accepted
time: 1ms
memory: 4248kb
input:
10000 1000000000 1 1333 666500000000 1333 666500000000 1333 666500000000 1333 666500000000 1333 666500000000 1333 666500000000 1333 666500000000 2000 1000000000000 1333 666500000000 1333 666500000000 1333 666500000000 1333 666500000000 1333 666500000000 1333 666500000000 1333 666500000000 1333 66650...
output:
6997500499999999
result:
ok single line: '6997500499999999'
Subtask #5:
score: 15
Accepted
Test #30:
score: 15
Accepted
time: 160ms
memory: 4916kb
input:
10000 8000000 5 1066 253 2000 50 353 1010 1465 1047 1430 1186 141 763 1217 1369 1234 52 435 1239 1151 810 1565 1424 1122 268 1239 1450 1483 1788 1226 1506 15 798 1366 167 1526 525 1949 1006 748 615 806 1740 1604 1420 1707 1999 16 1714 1211 310 459 804 89 1332 511 1374 683 193 287 1571 12 857 1775 15...
output:
9669913
result:
ok single line: '9669913'
Test #31:
score: 15
Accepted
time: 365ms
memory: 4876kb
input:
10000 5000000 5 185 1490 1549 795 658 948 1249 661 1006 279 1841 1924 629 93 1935 1920 1410 922 97 1306 197 391 1552 691 705 1264 1961 1651 1102 1191 159 691 184 1487 967 755 1998 1873 1418 1797 1396 1914 1206 416 625 1611 1950 158 1458 1032 581 1774 949 554 999 402 559 1517 1377 34 951 1314 276 792...
output:
8095579
result:
ok single line: '8095579'
Test #32:
score: 15
Accepted
time: 481ms
memory: 4856kb
input:
10000 3000000 5 3 532 1603 557 511 1421 326 1573 675 1933 1361 1108 865 1323 297 915 1632 627 344 1712 427 1431 1866 173 403 1706 1090 1585 889 1172 98 1782 1301 1073 54 1017 418 1474 106 334 1951 138 175 538 863 1473 971 103 970 229 709 1107 1290 741 1533 1137 1007 804 450 486 603 252 1850 413 551 ...
output:
6372898
result:
ok single line: '6372898'
Test #33:
score: 15
Accepted
time: 280ms
memory: 4856kb
input:
10000 5000000 4 1581 997 1112 710 179 260 892 720 1403 893 1806 1762 1061 286 1456 779 1894 22 616 1439 1574 780 1344 1187 1728 952 1591 1668 101 664 1566 1633 1769 1133 1595 1309 1269 235 1785 1582 1171 589 167 977 1717 1854 677 195 911 1536 762 265 920 1385 752 1593 301 98 1302 31 1566 1607 1293 1...
output:
8147513
result:
ok single line: '8147513'
Test #34:
score: 15
Accepted
time: 266ms
memory: 4876kb
input:
10000 5000000 3 1767 989 1332 702 726 1307 1518 167 1112 1563 1959 913 1661 716 1328 1163 1451 542 1089 809 1447 1607 515 1952 656 735 1220 910 1076 3 903 288 537 1733 145 873 390 186 45 1314 1559 1547 297 1268 1612 853 1575 496 42 809 1037 216 200 524 1589 755 116 1896 462 509 332 1353 729 84 165 1...
output:
8182118
result:
ok single line: '8182118'
Test #35:
score: 15
Accepted
time: 186ms
memory: 4856kb
input:
10000 5000000 2 392 92 1061 1576 574 1835 1198 1843 328 879 376 817 841 1717 1350 1937 98 1614 268 1607 30 1599 581 1896 1239 882 1200 738 782 644 1486 1698 1655 1093 1782 1579 554 667 1154 1494 1172 1919 1647 796 1092 462 801 270 1486 9 364 702 27 1717 860 1235 7 204 1262 1081 978 843 1461 287 1984...
output:
8112657
result:
ok single line: '8112657'
Test #36:
score: 15
Accepted
time: 128ms
memory: 6060kb
input:
10000 5000000 1 1786 1234 955 1670 1771 780 549 1681 845 1382 1405 604 672 1726 339 1460 329 1270 1423 1950 528 1 1850 1744 1601 1003 466 486 571 95 746 590 1571 1518 359 60 98 1454 548 375 915 1449 1471 282 1590 410 330 340 1984 1700 219 392 1577 794 284 286 76 1048 1243 432 618 1945 699 1982 599 1...
output:
8085639
result:
ok single line: '8085639'
Subtask #6:
score: 15
Accepted
Dependency #5:
100%
Accepted
Test #37:
score: 15
Accepted
time: 586ms
memory: 4940kb
input:
10000 8000000 20 842 734 1006 292 1743 917 77 744 596 5 1757 1487 580 1877 747 164 1373 367 1142 211 609 292 1362 60 854 503 904 727 471 1149 372 330 832 467 1542 500 501 1736 594 1238 508 1886 2000 1701 286 509 220 490 938 129 199 641 419 1527 580 381 1789 356 588 1923 1891 478 1643 58 1604 848 96 ...
output:
9638857
result:
ok single line: '9638857'
Test #38:
score: 15
Accepted
time: 1032ms
memory: 4920kb
input:
10000 5000000 20 1863 417 1617 1706 1234 1128 122 1886 315 1851 1559 252 1534 1454 295 1528 381 951 1245 474 1549 1552 751 1550 1895 998 394 389 1335 1756 827 227 1168 169 327 655 1447 1957 484 981 1828 1312 78 87 420 1836 1107 600 1513 78 1671 896 1928 801 1105 1627 570 226 1084 682 1164 1765 1687 ...
output:
8166287
result:
ok single line: '8166287'
Test #39:
score: 15
Accepted
time: 1285ms
memory: 4872kb
input:
10000 3000000 20 20 424 336 1547 475 1164 1112 377 1107 1911 1745 1578 504 1445 192 1716 1067 57 1618 837 433 216 1764 1770 1602 1243 1993 857 123 65 440 1416 1100 682 652 723 1051 509 1426 10 1184 147 686 768 1367 1017 1606 925 1 1170 1525 1885 994 1155 1754 1471 1892 1350 1558 1752 947 631 1970 73...
output:
6329258
result:
ok single line: '6329258'
Test #40:
score: 15
Accepted
time: 761ms
memory: 4856kb
input:
10000 5000000 15 1329 1049 1617 415 630 115 240 93 1440 1135 35 805 242 106 279 477 1443 805 1806 1681 95 195 606 191 1703 1311 656 9 780 356 577 343 616 1155 1683 354 1013 848 1133 42 1603 1957 39 1554 1543 1518 1888 462 1238 1468 840 1884 1566 642 790 392 1374 1259 1938 1526 1161 1842 1948 748 664...
output:
8151479
result:
ok single line: '8151479'
Test #41:
score: 15
Accepted
time: 564ms
memory: 5004kb
input:
10000 5000000 10 760 982 1460 967 1625 709 224 304 999 1542 976 913 694 1843 1248 398 1961 1001 1423 529 666 30 304 1606 408 949 1837 1149 548 1659 1615 364 1827 1807 375 1786 479 1905 505 149 406 1162 252 1661 985 1076 1627 615 414 1614 998 890 15 697 1602 533 1209 1565 1781 1415 1294 597 1035 1990...
output:
8192571
result:
ok single line: '8192571'
Test #42:
score: 15
Accepted
time: 1298ms
memory: 4936kb
input:
10000 2000000 20 1325 1272 1266 49 919 21 967 1360 1162 436 1879 79 1147 685 1000 298 1600 1195 1698 1214 1764 607 1891 814 1047 814 1723 1167 748 110 1616 1820 1178 1805 252 1730 812 10 554 1413 1393 1434 348 890 1084 1156 1368 1851 1220 133 662 646 278 254 916 734 1070 1809 2 1880 1138 1847 470 15...
output:
5177653
result:
ok single line: '5177653'
Test #43:
score: 15
Accepted
time: 692ms
memory: 4784kb
input:
10000 7000000 20 1828 115 1005 1931 1755 296 74 1882 526 1077 1723 516 1302 816 716 1393 1970 1460 1388 1118 82 529 1121 1038 575 1722 1490 1812 1841 805 1419 458 487 1295 1660 1117 1555 358 138 1566 107 429 1517 82 1082 1899 1521 739 604 1980 677 1454 1877 894 1726 1859 1227 1382 85 1976 1000 633 4...
output:
9305624
result:
ok single line: '9305624'
Subtask #7:
score: 30
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Dependency #3:
100%
Accepted
Dependency #4:
100%
Accepted
Dependency #5:
100%
Accepted
Dependency #6:
100%
Accepted
Test #44:
score: 30
Accepted
time: 1957ms
memory: 6004kb
input:
10000 24990001 20 4999 499899999980 4999 499899999980 5000 499999999980 5000 499999999980 4999 499899999980 5000 499999999980 4999 499899999980 4999 499899999980 4999 499899999980 5000 499999999980 5000 499999999980 4999 499899999980 4999 499899999980 5000 499999999980 5000 499999999980 5000 4999999...
output:
2499000099900020
result:
ok single line: '2499000099900020'
Test #45:
score: 30
Accepted
time: 3070ms
memory: 5940kb
input:
10000 20000000 16 4223 419 4924 4214 4547 70 4117 2642 4278 4251 4785 4660 4122 3970 4528 4678 4371 1441 4580 3927 4474 4768 4467 1316 4323 3605 4424 1794 4358 3497 4610 2054 4884 2698 4895 2789 4367 3303 4994 3852 4098 2087 4868 1345 4658 4818 4668 1895 4314 1238 4583 4503 4234 1131 4367 4002 4684 ...
output:
17238826
result:
ok single line: '17238826'
Test #46:
score: 30
Accepted
time: 2848ms
memory: 6000kb
input:
10000 20000000 14 4855 2383 4883 618 4704 4038 4182 1765 4476 78 4180 4977 4582 96 4590 3319 4233 2294 4756 3109 4856 3520 4266 227 4147 1384 4332 3399 4051 2957 4424 761 4716 2588 4450 2295 4366 3970 4556 1946 4623 1027 4158 4120 4280 255 4541 2896 4090 879 4323 1 4029 3220 4563 4739 4946 2169 4569...
output:
17398304
result:
ok single line: '17398304'
Test #47:
score: 30
Accepted
time: 2026ms
memory: 6004kb
input:
10000 20000000 16 4083 1955 4715 4442 3825 3360 3349 1183 4072 3344 3893 884 3164 1464 3800 4171 3157 4651 3316 1528 4656 2966 3091 1537 4355 4605 4644 4596 3780 429 3267 1777 3193 3264 3059 3316 4105 2876 3826 3109 4633 4780 4954 1271 4716 4365 3340 756 4542 3002 3444 4367 4854 2473 3986 3848 3644 ...
output:
18812257
result:
ok single line: '18812257'
Test #48:
score: 30
Accepted
time: 1184ms
memory: 5968kb
input:
10000 20000000 17 142 3149 1878 216 2563 3817 1540 4364 1370 1408 1142 3162 1579 4422 414 535 3188 2223 275 2705 3692 1661 16 3868 2409 2590 3675 3073 4555 116 3175 2978 574 4539 2026 4624 3124 3485 1224 1485 1401 4601 862 2602 3485 4992 1336 554 2926 3552 587 61 1811 1393 3355 238 4090 2306 3199 41...
output:
24214039
result:
ok single line: '24214039'
Test #49:
score: 30
Accepted
time: 2641ms
memory: 5924kb
input:
10000 15992000 20 4754 47536 4000 40010 4692 46919 4084 40835 3999 40000 3999 40000 4521 45200 3999 40000 342 3413 3999 40000 4000 40010 2525 25243 2858 28574 4496 44951 4000 40010 1393 13929 3606 36055 4000 40010 3999 40000 3999 40000 4754 47532 3999 40000 3999 40000 3999 40000 3999 40000 4191 4190...
output:
159959979
result:
ok single line: '159959979'
Test #50:
score: 30
Accepted
time: 2066ms
memory: 5944kb
input:
10000 20000000 11 4937 493699999999 4955 495499999999 4964 496400000000 4935 493499999999 4902 490200000000 4926 492599999999 4955 495499999999 4907 490700000000 4952 495200000000 5000 500000000000 4930 493000000000 4958 495799999999 4962 496199999999 4946 494600000000 4908 490800000000 4993 4992999...
output:
2000000000000000
result:
ok single line: '2000000000000000'
Test #51:
score: 30
Accepted
time: 1922ms
memory: 5864kb
input:
10000 24995000 20 4999 4998999999 4999 4998999999 5000 4999999999 4999 4998999999 5000 4999999999 5000 4999999999 4999 4998999999 5000 4999999999 4999 4998999999 4999 4998999999 4999 4998999999 4999 4998999999 5000 4999999999 4999 4998999999 5000 4999999999 4999 4998999999 5000 4999999999 4999 49989...
output:
24994999995001
result:
ok single line: '24994999995001'
Test #52:
score: 30
Accepted
time: 2133ms
memory: 5944kb
input:
10000 22495500 20 5000 4999999998 5000 4999999998 5000 4999999998 4999 4998999998 4999 4998999998 5000 4999999998 4999 4998999998 5000 4999999998 5000 4999999998 4999 4998999998 5000 4999999998 5000 4999999998 4999 4998999998 4999 4998999998 4999 4998999998 5000 4999999998 4238 42379169 2362 2361958...
output:
22495499991000
result:
ok single line: '22495499991000'
Test #53:
score: 30
Accepted
time: 2009ms
memory: 5984kb
input:
9600 21726165 20 4351 43509738 5000 4999999997 4999 4998999997 4999 4998999997 4999 4998999997 5000 4999999997 4999 4998999997 3620 36199648 5000 4999999997 4999 4998999997 5000 4999999997 4999 4998999997 5000 4999999997 5000 4999999997 5000 4999999997 4999 4998999997 5000 4999999997 4999 4998999997...
output:
44541741079859
result:
ok single line: '44541741079859'
Test #54:
score: 30
Accepted
time: 2055ms
memory: 5948kb
input:
10000 23014987 20 4999 4998999996 5000 4999999996 4999 4998999996 5000 4999999996 5000 4999999996 3457 34569293 4016 40159726 5000 4999999996 5000 4999999996 5000 4999999996 4999 4998999996 5000 4999999996 4999 4998999996 5000 4999999996 5000 4999999996 4999 4998999996 5000 4999999996 5000 499999999...
output:
74443172109428
result:
ok single line: '74443172109428'
Test #55:
score: 30
Accepted
time: 1857ms
memory: 5860kb
input:
9200 21258797 20 5000 4999999995 5000 4999999995 5000 4999999995 4999 4998999995 5000 4999999995 4999 4998999995 5000 4999999995 5000 4999999995 4999 4998999995 5000 4999999995 4999 4998999995 4999 4998999995 4999 4998999995 1210 12099316 4999 4998999995 5000 4999999995 5000 4999999995 4999 49989999...
output:
96784187253087
result:
ok single line: '96784187253087'
Test #56:
score: 30
Accepted
time: 1978ms
memory: 5868kb
input:
10000 23521884 20 4999 4998999994 4056 40559071 5000 4999999994 5000 4999999994 5000 4999999994 5000 4999999994 1633 16329842 2565 256497483799 4999 4998999994 4999 4998999994 4999 4998999994 5000 4999999994 5000 4999999994 4999 4998999994 5000 4999999994 4999 4998999994 4999 4998999994 4999 4998999...
output:
125131877059940
result:
ok single line: '125131877059940'
Test #57:
score: 30
Accepted
time: 1706ms
memory: 6028kb
input:
8800 20771646 20 5000 4999999993 5000 4999999993 5000 4999999993 4999 4998999993 5000 4999999993 4999 4998999993 2726 272593228017 4999 4998999993 4999 4998999993 5000 4999999993 5000 4999999993 4999 4998999993 113 11292372866 4999 4998999993 4999 4998999993 5000 4999999993 4999 4998999993 4999 4998...
output:
147048130793970
result:
ok single line: '147048130793970'
Test #58:
score: 30
Accepted
time: 1900ms
memory: 6068kb
input:
10000 24037418 20 4999 4998999992 5000 4999999992 4999 4998999992 5000 4999999992 5000 4999999992 4999 4998999992 5000 4999999992 2260 225998259007 5000 4999999992 5000 4999999992 4999 4998999992 5000 4999999992 5000 4999999992 4999 4998999992 4999 4998999992 4999 4998999992 3947 394690054935 5000 4...
output:
176684392530476
result:
ok single line: '176684392530476'
Test #59:
score: 30
Accepted
time: 1541ms
memory: 5904kb
input:
8400 20255621 20 4999 4998999991 4999 4998999991 4999 4998999991 4999 4998999991 5000 4999999991 4999 4998999991 4999 4998999991 5000 4999999991 5000 4999999991 5000 4999999991 5000 4999999991 5000 4999999991 5000 4999999991 5000 4999999991 4999 4998999991 4999 4998999991 5000 4999999991 4999 499899...
output:
194424884792687
result:
ok single line: '194424884792687'
Test #60:
score: 30
Accepted
time: 1847ms
memory: 5924kb
input:
10000 24443700 20 4999 4998999990 4999 4998999990 5000 4999999990 5000 4999999990 5000 4999999990 4999 4998999990 4999 4998999990 4999 4998999990 5000 4999999990 1309 130896707094 4999 4998999990 4999 4998999990 5000 4999999990 5000 4999999990 5000 4999999990 4999 4998999990 5000 4999999990 4999 499...
output:
217311388155884
result:
ok single line: '217311388155884'
Test #61:
score: 30
Accepted
time: 1419ms
memory: 5944kb
input:
8000 19763015 20 5000 4999999989 5000 4999999989 4999 4998999989 4999 4998999989 5000 4999999989 5000 4999999989 2085 208493579138 5000 4999999989 5000 4999999989 5000 4999999989 5000 4999999989 4999 4998999989 4999 4998999989 5000 4999999989 5000 4999999989 5000 4999999989 4999 4998999989 5000 4999...
output:
244143339253943
result:
ok single line: '244143339253943'
Test #62:
score: 30
Accepted
time: 1763ms
memory: 6000kb
input:
10000 25008413 20 5000 4999999988 4999 4998999988 5000 4999999988 2899 289899747125 5000 4999999988 4999 4998999988 4999 4998999988 4999 4998999988 5000 4999999988 4999 4998999988 5000 4999999988 5000 4999999988 4999 4998999988 4999 4998999988 4999 4998999988 4634 463397985043 5000 4999999988 5000 4...
output:
273782036748886
result:
ok single line: '273782036748886'
Test #63:
score: 30
Accepted
time: 1570ms
memory: 6004kb
input:
10000 24982188 20 4999 4998999987 4999 4998999987 4651 465093229966 5000 4999999987 2800 279997651588 5000 4999999987 4999 4998999987 4999 4998999987 5000 4999999987 5000 4999999987 5000 4999999987 4999 4998999987 5000 4999999987 5000 4999999987 5000 4999999987 4681 468093594666 4999 4998999987 4999...
output:
518604886343275
result:
ok single line: '518604886343275'
Test #64:
score: 30
Accepted
time: 1756ms
memory: 5916kb
input:
10000 23792100 20 4999 4998999986 3325 332493423563 4999 4998999986 5000 4999999986 4999 4998999986 4999 4998999986 5000 4999999986 5000 4999999986 4999 4998999986 4999 4998999986 2071 207095429977 5000 4999999986 5000 4999999986 539 53892756161 5000 4999999986 4999 4998999986 5000 4999999986 4999 4...
output:
399598500571133
result:
ok single line: '399598500571133'
Test #65:
score: 30
Accepted
time: 1949ms
memory: 5848kb
input:
10000 22502854 20 5000 4999999985 5000 4999999985 5000 4999999985 3637 363693097796 502 50191152908 4999 4998999985 4999 4998999985 4999 4998999985 5000 4999999985 5000 4999999985 5000 4999999985 5000 4999999985 4999 4998999985 4999 4998999985 5000 4999999985 5000 4999999985 5000 4999999985 5000 499...
output:
270676410478894
result:
ok single line: '270676410478894'
Test #66:
score: 30
Accepted
time: 2131ms
memory: 5940kb
input:
10000 21255962 20 2225 22249948 1532 15319031 5000 4999999984 4016 401590865731 4999 4998999984 2236 223592646098 4999 4998999984 5000 4999999984 5000 4999999984 4999 4998999984 3044 30439760 4301 43009455 4999 4998999984 4999 4998999984 5000 4999999984 5000 4999999984 5000 4999999984 5000 499999998...
output:
145989754008033
result:
ok single line: '145989754008033'
Test #67:
score: 30
Accepted
time: 2362ms
memory: 6068kb
input:
10000 19996000 20 5000 4999999983 5000 4999999983 4999 4998999983 545 5449047 4999 4998999983 4999 4998999983 5000 4999999983 4999 4998999983 518 5179118 3886 38859962 5000 4999999983 4999 4998999983 1940 19399084 690 6899402 4999 4998999983 5000 4999999983 4999 4998999983 4999 4998999983 4999 49989...
output:
19995999932000
result:
ok single line: '19995999932000'
Test #68:
score: 30
Accepted
time: 1954ms
memory: 6064kb
input:
9900 24495100 20 4999 4998999982 4999 4998999982 5000 4999999982 5000 4999999982 4999 4998999982 4999 4998999982 5000 4999999982 4999 4998999982 5000 4999999982 4999 4998999982 5000 4999999982 4999 4998999982 4999 4998999982 5000 4999999982 4999 4998999982 5000 4999999982 5000 4999999982 5000 499999...
output:
24495099911800
result:
ok single line: '24495099911800'
Test #69:
score: 30
Accepted
time: 1933ms
memory: 6056kb
input:
9900 24627666 20 5000 4999999981 4999 4998999981 5000 4999999981 5000 4999999981 5000 4999999981 4999 4998999981 5000 4999999981 4999 4998999981 4999 4998999981 5000 4999999981 4999 4998999981 5000 4999999981 5000 4999999981 4999 4998999981 4999 4998999981 5000 4999999981 5000 4999999981 5000 499999...
output:
37751427117025
result:
ok single line: '37751427117025'
Test #70:
score: 30
Accepted
time: 1954ms
memory: 5928kb
input:
9900 24755580 20 4999 4998999980 5000 4999999980 4999 4998999980 1483 148292401980 4999 4998999980 5000 4999999980 4999 4998999980 4999 4998999980 4999 4998999980 4999 4998999980 4999 4998999980 656 65591594686 4999 4998999980 4999 4998999980 4999 4998999980 5000 4999999980 4999 4998999980 5000 4999...
output:
50542593847047
result:
ok single line: '50542593847047'
Extra Test:
score: 0
Extra Test Passed