QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#120153 | #6194. Knapsack Problem | hos_lyric | AC ✓ | 4ms | 3856kb | C++14 | 7.7kb | 2023-07-06 14:16:45 | 2023-07-06 14:18:08 |
Judging History
answer
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }
#define foreach(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
using wint = Int;
struct Row { int j, p; wint v; };
struct Col { int i, p; };
struct Mat {
vector<vector<Row>> rs;
vector<vector<Col>> cs;
void append(int i, int j, wint val) {
if (i >= (int)rs.size()) rs.resize(i + 1);
if (j >= (int)cs.size()) cs.resize(j + 1);
if (val == 0) return;
rs[i].push_back({j, (int)cs[j].size(), val});
cs[j].push_back({i, (int)rs[i].size() - 1});
}
void remove(Row &r) {
if (r.p + 1 < (int)cs[r.j].size()) { Col &c = cs[r.j].back(); cs[r.j][rs[c.i][c.p].p = r.p] = c; }
cs[r.j].pop_back();
}
void remove(Col &c) {
if (c.p + 1 < (int)rs[c.i].size()) { Row &r = rs[c.i].back(); rs[c.i][cs[r.j][r.p].p = c.p] = r; }
rs[c.i].pop_back();
}
void remove(int i, int k) {
Row r = rs[i][k]; remove(cs[r.j][r.p]); remove(r);
}
void clearRow(int i) {
foreach (it, rs[i]) { remove(*it); } rs[i].clear();
}
void clearCol(int j) {
foreach (it, cs[j]) { remove(*it); } cs[j].clear();
}
wint operator()(int i, int j) {
foreach (it, rs[i]) { if (it->j == j) return it->v; } return 0;
}
wint operator()(Col &c) {
return rs[c.i][c.p].v;
}
};
struct Tab {
Mat D;
vector<int> id;
vector<wint> tmp;
Tab(Mat A, vector<wint> b, vector<wint> c) : id(b.size() + 1) {
int m = b.size(), n = c.size();
for (int i = 0; i < m; ++i) foreach (it, A.rs[i]) D.append(1 + i, 1 + it->j, it->v);
for (int i = 0; i < m; ++i) D.append(1 + i, 0, b[i]);
for (int j = 0; j < n; ++j) D.append(0, 1 + j, -c[j]);
for (int i = 0; i <= m; ++i) { id[i] = 1 + n + i; D.append(i, 1 + n + i, 1); }
}
wint idv(int i) {
return D(D.cs[id[i]][0]);
}
wint val(vector<wint> &x) {
x.assign(id[0] - 1, 0);
for (int i = 0; i < (int)id.size(); ++i) if (id[i] < id[0]) x[id[i] - 1] = D(i, 0) / idv(i);
return D(0, 0) / idv(0);
}
void pivot(int r, int s) {
if (tmp.size() < D.cs.size()) tmp.resize(D.cs.size(), 0);
wint mul = (D(r, s) < 0) ? -1 : 1; foreach (it, D.rs[r]) tmp[it->j] = (it->v *= mul);
vector<Col> cs = D.cs[s];
foreach (it, cs) if (it->i != r) {
wint d = D(*it), pv = tmp[s]; vector<Row> &rs = D.rs[it->i];
for (int k = 0; k < (int)rs.size(); ++k) {
rs[k].v = rs[k].v * pv - tmp[rs[k].j] * d; tmp[rs[k].j] = 0;
if (rs[k].v == 0) D.remove(it->i, k--);
}
foreach (jt, D.rs[r]) {
if (tmp[jt->j] == 0) tmp[jt->j] = jt->v; else D.append(it->i, jt->j, -jt->v * d);
}
wint g = 0; foreach (jt, rs) g = __gcd(jt->v, g); if (g < 0) g = -g;
foreach (jt, rs) jt->v /= g;
}
foreach (it, D.rs[r]) { tmp[it->j] = 0; } id[r] = s;
}
void simplex() {
for (int i = 1; i < (int)id.size(); ++i) if (D.rs[i].size() > 1) {
bool ok = 1;
foreach (it, D.rs[i]) if (it->j == 0 || it->v < 0) ok = 0;
if (ok) { vector<Row> rs = D.rs[i]; foreach (it, rs) if (it->j != id[i]) D.clearCol(it->j); }
}
if (tmp.size() < D.cs.size()) tmp.resize(D.cs.size(), 0);
for (; ; ) {
int r = 0, s = 0;
foreach (it, D.cs[0]) if (it->i > 0 && (r == 0 || id[r] > id[it->i]) && D(*it) < 0) r = it->i;
if (r == 0) break;
wint t = 0;
foreach (it, D.rs[0]) tmp[it->j] = it->v;
foreach (it, D.rs[r]) if (it->j > 0 && it->v < 0) {
wint d = tmp[it->j] * t - tmp[s] * it->v;
if (s == 0 || d > 0 || (d == 0 && s > it->j)) { s = it->j; t = it->v; }
}
foreach (it, D.rs[0]) tmp[it->j] = 0;
if (s == 0) throw "infeasible";
pivot(r, s);
}
}
void crisscross() {
for (int INF = 1001001001; ; ) {
int r = 0, s = INF;
foreach (it, D.cs[0]) if (it->i > 0 && (r == 0 || id[r] > id[it->i]) && D(*it) < 0) r = it->i;
foreach (it, D.rs[0]) if (it->j > 0 && it->v < 0) chmin(s, it->j);
if (r == 0 && s == INF) break;
if (r > 0 && id[r] < s) {
s = INF;
foreach (it, D.rs[r]) if (it->j > 0 && it->v < 0) chmin(s, it->j);
if (s == INF) throw "primal infeasible";
} else {
r = 0;
foreach (it, D.cs[s]) if ((r == 0 || id[r] > id[it->i]) && D(*it) > 0) r = it->i;
if (r == 0) throw "dual infeasible";
}
pivot(r, s);
}
}
};
wint floorDiv(wint a, wint b) {
return (a >= 0) ? (a / b) : ((a - b + 1) / b);
}
void branch(Tab &t, int i, int k, wint f) {
int n = t.id.size(), m = t.D.cs.size();
t.id.push_back(m); t.D.append(n, 0, f); t.D.append(n, t.id[i], k); t.D.append(n, m, 1); t.pivot(i, t.id[i]);
}
int select(Tab &t) {
for (int i = 0; i < (int)t.id.size(); ++i) if (t.id[i] < t.id[0] && t.D(i, 0) % t.idv(i) != 0) return i;
return 0;
}
bool IPDfs(Tab &t, vector<wint> &x, wint lb) {
try {
t.simplex(); wint t0 = t.D(0, 0), ti = t.idv(0); if (t0 < lb * ti) return 0; vector<Row> rs = t.D.rs[0];
foreach (it, rs) if (it->j > 0 && it->j != t.id[0] && t0 - it->v < lb * ti) t.D.clearCol(it->j);
int i = select(t);
if (i == 0) {
t.val(x); return 1;
} else {
wint f = floorDiv(t.D(i, 0), t.idv(i));
Tab tt = t;
branch(tt, i, -1, -f - 1); if (IPDfs(tt, x, lb)) return 1;
branch(t, i, 1, f); if (IPDfs(t, x, lb)) return 1;
}
} catch (...) {
}
return 0;
}
// max c.x subject to x >= 0, A x <= b
wint IP(Mat A, vector<wint> b, vector<wint> c, vector<wint> &x) {
Tab t(A, b, c); t.crisscross();
for (wint lb = floorDiv(t.D(0, 0), t.idv(0)); ; --lb) { Tab tt = t; if (IPDfs(tt, x, lb)) return lb; }
}
int K;
Int C[1 << 4], D[4];
int main() {
for (int numCases; ~scanf("%d", &numCases); ) { for (int caseId = 1; caseId <= numCases; ++caseId) {
scanf("%d", &K);
for (int h = 1; h < 1 << K; ++h) {
scanf("%lld", &C[h]);
}
for (int i = 0; i < K; ++i) {
scanf("%lld", &D[i]);
}
Mat A;
vector<wint> b;
{
int row = 0;
for (int i = 0; i < K; ++i) {
for (const int sig : {+1, -1}) {
for (int h = 1; h < 1 << K; ++h) if (h >> i & 1) {
// cerr<<"A["<<row<<"]["<<h<<"] = "<<sig<<endl;
A.append(row, h - 1, sig);
}
++row;
b.push_back(sig * D[i]);
}
}
}
const vector<wint> c(C + 1, C + (1 << K));
// cerr<<"b = "<<b<<endl;
// cerr<<"c = "<<c<<endl;
vector<wint> x;
try {
const wint ans = IP(A, b, c, x);
printf("%lld\n", ans);
} catch (const char *msg) {
cerr << "HELP " << msg << endl;
}
}
#ifndef LOCAL
break;
#endif
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3748kb
input:
3 2 1 2 4 4 5 3 3226252 19270256 2430652 1187613 12496062 10286165 17494834 24 85 34 4 901133 6693218 13245489 14740234 16186210 11382783 19277321 3855635 16523184 10168517 16195031 971041 10303441 8395899 11618555 529321239 218214127 92942310 207467810
output:
18 1949753378 7832404777567179
result:
ok 3 number(s): "18 1949753378 7832404777567179"
Test #2:
score: 0
Accepted
time: 3ms
memory: 3824kb
input:
100 4 4488409 9842893 14331290 11289097 15777479 21131954 25620334 6146092 10634508 15988956 20477387 17435190 21923584 27278027 31766493 200477197 258791439 590664017 982949628 4 5484152 19851747 25335961 6555937 12039831 26407861 31891996 10897184 16381166 30749333 36233145 17453055 22937114 37304...
output:
16156444320083421 24565535429631234 29418802996321901 30685727712782520 21026118053726857 27272339796311010 28831028447377015 34577176834491128 9058894962996375 21525085254465501 6657186892229297 16750628911275484 11217846865301187 12674726744043780 33873234230125448 3890237279573366 319038768614465...
result:
ok 100 numbers
Test #3:
score: 0
Accepted
time: 3ms
memory: 3792kb
input:
100 4 11618334 18295966 29914477 5116382 16734869 23412289 35030567 15002473 26620994 33298395 44916782 20118655 31737127 38414456 50032872 52573649 733715025 105771527 204824011 4 2142433 13679527 15822005 7304783 9447231 20984363 23126840 6271380 8413827 19950941 22093291 13576168 15718643 2725577...
output:
17648887427676796 21625331519839488 5123483163674640 20332898488476516 10882410276737710 25799406290369942 9021794681785918 14079661025657823 19651479225495798 19108340996997031 7502197529195960 14859286025000990 26534486448012504 21196964793845212 17222108748663918 19112873745810973 150116234459639...
result:
ok 100 numbers
Test #4:
score: 0
Accepted
time: 3ms
memory: 3704kb
input:
100 4 19912840 5584811 25497404 10173442 30086113 15758284 35670730 10055784 29968204 15640365 35553036 20228929 40141706 25813818 45726645 199637398 648830099 620879036 721665690 4 7571016 7507237 15078004 19283701 26854580 26790914 34361725 2809630 10380467 10316661 17887650 22093187 29664080 2960...
output:
21172351446279597 12216316207781859 31685774482329793 36066732654517313 19340822375673782 17094361082328640 19075803268324489 23946411427126244 15750520513128720 10839993372177143 28038252774564427 12098359408203383 16661717061725678 16141878677697603 10422881545500853 23195259150880456 161145733965...
result:
ok 100 numbers
Test #5:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
100 4 16976932 14037962 31014864 10197492 27174564 24235473 41212439 18912005 35888926 32949719 49926702 29109585 46086485 43147299 60124270 491925338 268977876 990762353 88764265 4 12999234 10104744 23104060 1196740 14196165 11301451 24300745 3216693 16215855 13321348 26320916 4413380 17412748 1451...
output:
23909367397934013 13788681506670460 23733351389222421 14554685971742458 21700214066873395 14675080284915330 33895419440563729 29492673616768327 11303756472296747 12482610599433273 14710253245102988 30271020171688425 9134330469412563 33975992434656396 17398716116891428 24545212510786538 3194464768874...
result:
ok 100 numbers
Test #6:
score: 0
Accepted
time: 3ms
memory: 3704kb
input:
100 4 19074076 1326772 20400846 10221739 29295815 11548536 30622598 8932278 28006379 10259062 29333181 19154053 38228108 20480879 39554936 638989087 594158358 505869863 605605944 4 4624862 3932439 8557338 1945542 6570437 5877999 10502871 4787691 9412557 8720153 13345006 6733262 11358122 10665669 152...
output:
23556800109725722 10537032002627174 14660751629073194 20011815419177543 22625965024389053 11033496376968227 17546765754659334 27441279970436335 34448070575909396 25397224562147617 10757782582321602 16008699146950819 10145064828196714 41523392253608928 20626446413714925 32072152342903207 720635465608...
result:
ok 100 numbers
Test #7:
score: 0
Accepted
time: 4ms
memory: 3696kb
input:
100 4 1171312 9779739 10950939 15278965 16449994 25058569 26229921 2821649 3992612 12601354 13772604 18100248 19271474 27880146 29051284 786052835 69081944 20977372 827480328 4 15086110 17760131 32846218 13924280 29010738 31684453 46770885 15128745 30215077 32888809 47975302 29053233 44139622 468134...
output:
4251688072802988 38416920079725055 6532611509976464 40289090747797420 5302425059666288 24716122297246780 40775392402414505 7056563165740518 17529843593302808 12819105623258024 20531058461804092 18722825798670288 33134881338491166 14337748949215833 28205390066848386 18508938475970114 1464607434360399...
result:
ok 100 numbers
Test #8:
score: 0
Accepted
time: 4ms
memory: 3700kb
input:
100 4 3268337 18232898 21501303 9105978 12374475 27338971 30607287 11677818 14946177 29910672 33178912 20783747 24052133 39016627 42285057 783373480 689229722 536084881 344322007 4 5547703 11587692 17135387 870321 6417974 12457985 18005620 15535900 21083520 27123601 32671264 16406183 21953851 279938...
output:
24029593865073835 17357370523557614 7754333149525536 24770903948059615 14829362656077913 13853154752037552 22856229602033323 23897428200156414 17506334124779784 16507611157738008 21743814085856734 27158737156121400 14411231424407837 12391527972875238 23916408781407438 24317152966273698 7400547834361...
result:
ok 100 numbers
Test #9:
score: 0
Accepted
time: 1ms
memory: 3856kb
input:
100 4 5365456 5521877 10887385 9130162 14495850 14651940 20017468 6731144 12096612 12252742 17618423 15861269 21226812 21383080 26748653 930437229 309377499 905968199 566196390 4 17173130 5415382 22588448 1619174 18792328 7034555 24207585 12074036 29247238 17489345 34662518 13693236 30866361 1910850...
output:
18783561823107173 17174759455871110 20660176070779614 32551394415335213 14757437903189281 14353521145985327 8825454958613940 18626834204122338 23538161187858980 9768340101299130 10856044914259908 13798985739347606 28560306475402613 9937141276845409 22030208362253896 10007043951392399 932418252758094...
result:
ok 100 numbers
Test #10:
score: 0
Accepted
time: 3ms
memory: 3700kb
input:
100 4 8626843 13974903 22601547 9154419 17781333 23129257 31755964 15587325 24214126 29562230 38188966 24741851 33368575 38716644 47343335 77500977 784301085 421075708 933294965 4 2601585 19242893 21844460 8564983 11166697 27808106 30409548 7448057 10049691 26690992 29292813 16013341 18614976 352562...
output:
30031441828206913 23706173942582594 35850620790374689 12248181406938398 3569227446883530 27644763176419295 20081336598385059 22229155823622873 32305575190424382 28752041038252008 7011854183413928 28284434195685860 23754711092334182 21112877189703804 21779236766630770 11439389176833922 16936798822777...
result:
ok 100 numbers
Test #11:
score: 0
Accepted
time: 1ms
memory: 3772kb
input:
100 4 13688404 12628879 26317621 5351629 19040005 17980387 31669079 14469291 28157775 27098440 40786668 19820709 33509247 32449794 46138396 116132017 898003516 839972106 892258556 4 6839726 3899287 10739121 113756 6953512 4013022 10852729 18786521 25626326 22685885 29525686 18900424 25740120 2279973...
output:
30336258507082714 3257768626402136 28768287749346077 24983778209266624 33337982642789783 8256725694468078 22292037981448585 18920943294190842 19458942341010512 8558313401862953 15215499555800050 16557870271025505 19252729255629219 5089861441915246 20378861002078977 20236585760009299 1513702155613423...
result:
ok 100 numbers
Test #12:
score: 0
Accepted
time: 4ms
memory: 3772kb
input:
100 4 818632 14885007 15703632 10408690 11227157 25293691 26112291 9522508 10341287 24407621 25226174 19931188 20749827 34816087 35634914 408419958 223183998 355079615 259357132 4 12268258 17726903 29995137 7059674 19327948 24786537 37054795 14160661 26428894 31887596 44155812 21220340 33488624 3894...
output:
9822123147255252 25706707261441731 30764683969228288 20463407949651199 13119143982680734 4511209144591007 17206988115593070 21613410637449924 6063335219524613 28247599960704248 20398515507252217 7805031270286406 43671110708013807 16822872474944611 26966106568765306 38046693018932635 2288946869140619...
result:
ok 100 numbers
Test #13:
score: 0
Accepted
time: 3ms
memory: 3784kb
input:
100 4 17882885 3338008 21220862 10432804 28315706 13770867 31653699 18378803 36261713 21716859 39599725 28811677 46694515 32149718 50032575 555483706 843331776 165154420 481231515 4 3893831 6521669 10415260 7808579 11702235 14330241 18223833 15731888 19625524 22253365 26147241 23540433 27434140 3006...
output:
23316214536490063 22139250765511441 22281944987058948 22368379936792866 6094559071158787 14179808411937036 19848270480774283 31800041401313086 24430928137055338 21245647160267298 28720402198184113 21139760374401571 21459062813217036 19167200380594251 9060291570904319 3342348642918590 372868618667565...
result:
ok 100 numbers
Test #14:
score: 0
Accepted
time: 3ms
memory: 3764kb
input:
100 4 19979998 16823957 36803975 9292880 29272968 26116922 46096896 7235120 27215075 24059121 44039142 16528036 36508026 33351962 53332011 702547455 318255361 680261930 998073194 4 14355044 349066 14704372 14754399 29109766 15103602 29458750 11105765 25461150 11454966 25810188 25860282 40215498 2620...
output:
32934058805096906 25248650232118286 20596963895757786 34296109369076807 21170591453952093 15297730643210559 16658113449947174 9285254128055933 34409107094899036 8409398361229868 14654898814118327 12882322998656289 16980505536456191 26326071351987652 18205368491874005 20853765326283413 17881088390515...
result:
ok 100 numbers
Test #15:
score: 0
Accepted
time: 3ms
memory: 3708kb
input:
100 4 17044248 4112972 21157245 9317154 26361378 13429981 30474311 17255524 34299701 21368436 38412668 26572547 43616815 30685502 47729715 699868099 938403139 50145247 219947577 4 4816545 19209766 24026173 6733364 11549723 25943055 30759506 1447072 6263517 20656762 25473255 8180303 12997037 27390049...
output:
20050890461098521 16912986526374868 21395331075748195 24898058411192152 36485811506417772 17311235865468642 17925280122419906 11111113690525656 13421491226187821 13213904255347673 34865058086495745 11627028614759309 40775602040671470 19189429429150267 14271915906028964 22814864282246034 242839763740...
result:
ok 100 numbers
Test #16:
score: 0
Accepted
time: 3ms
memory: 3788kb
input:
100 4 19141397 12565949 31707357 14374230 33515636 26940179 46081570 6111747 25253153 18677695 37819100 20485971 39627374 33051924 52193313 846931848 558550917 565252756 736789257 4 16442041 8004517 24446538 2449341 18891242 10453678 26895842 8051090 24493177 16055658 32497644 10500335 26942383 1850...
output:
35858332464905214 20976717070872097 30351720630237411 10601652628680713 38546165484582341 24651487370072888 4944034566488499 12944848325784268 25939954955376921 28520959651899839 24903571220134037 25756378650658020 11261464488494142 29430266128657295 14649854693522165 17227969937977500 2733110955707...
result:
ok 100 numbers
Test #17:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
100 2 12167161 5799299 17966463 112370761 157416002 2 17886736 5898036 23784804 190891670 938742153 2 19161692 14848619 34010323 408355227 373975737 2 19757131 10504373 30261457 458863791 747726339 2 15181356 6678700 21859931 469240789 28698166 2 18400074 173733 18574024 762103643 40447721 2 1485017...
output:
2280135940874402 8951170027534068 13377804808030131 16920228396724068 7315377908794084 14029799307937532 23542852816423472 12019080917094672 5500254122685290 1777123414550942 18992670569600186 12277060713042936 11479435499933806 18642876532604270 30475687415994819 6535374083161607 3575862683781468 4...
result:
ok 100 numbers
Test #18:
score: 0
Accepted
time: 0ms
memory: 3748kb
input:
100 3 11925575 11719553 23645133 14377862 26303405 26097257 38022905 794976318 501014308 681521306 3 839381 15844190 16683438 1710956 2550292 17555093 18394561 17132802 926345869 984282669 3 736197 4998174 5734346 6022367 6758535 11020533 11756694 678670553 636059210 748298414 3 14905809 11834557 26...
output:
25151035232696486 16375645823363504 8185297505615419 12549523102068159 12230231484894479 5970814852888599 16785730816333659 14128817750481004 19433389708161550 9891498191151937 19116999247570263 17311652767472196 5559919144649117 19619241222518636 10761057132675212 16669420283317066 3556726375160672...
result:
ok 100 numbers
Test #19:
score: 0
Accepted
time: 2ms
memory: 3800kb
input:
100 3 1398110 14355699 15753959 7519346 8917294 21875119 23273057 117399159 401129991 20138223 3 15888817 1195450 17084384 3020634 18909385 4216042 20104889 129823746 392285344 730246165 3 10602318 13060613 23662795 19755547 30357988 32816092 43418502 390348825 512692916 326802037 3 14804361 1596059...
output:
6074083715522709 4737524840680174 17290879335593648 21634861743683904 22591422629959295 16068955594656119 14290789976303262 10175103769091053 3312016596514584 5803987962708996 7199218331698896 15673496527611471 4477427975441035 17978570839593433 1956074950574761 6582326394471792 7930996191194370 141...
result:
ok 100 numbers
Test #20:
score: 0
Accepted
time: 2ms
memory: 3748kb
input:
100 3 19558798 612816 20171414 3076627 22635434 3689396 23248032 258439246 528152900 475496469 3 1148149 9114227 10262347 906132 2054308 10020301 11168454 81233604 393257697 46762902 3 9056543 12118037 21174594 18178138 27234755 30296217 39352969 772532381 334579913 101264205 3 10077223 11333001 214...
output:
6841349156235985 3719882825667633 12891747869295321 11695520906281570 37180875867880530 6644013298466961 5668734620052918 11291341370348957 6719823255474322 15432131283956712 11650903692612800 7915324364346091 18855530350491017 26635367303669759 5679603563164156 14679848112083424 27255392135239333 2...
result:
ok 100 numbers
Test #21:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
1 4 18771096 16554401 35325702 15547759 34318962 32102165 50873353 15784482 34555700 32339072 51110134 31332365 50103626 47886724 66658013 385018454 60751498 94584456 207814234
output:
12983792986996964
result:
ok 1 number(s): "12983792986996964"
Test #22:
score: 0
Accepted
time: 0ms
memory: 3712kb
input:
1 4 14769335 821915 15591268 6115422 20884779 6937520 21706890 8427993 23197272 9249953 24019354 14543492 29312817 15365534 30134897 138925583 433937978 735338247 427156305
output:
10505582771919122
result:
ok 1 number(s): "10505582771919122"
Test #23:
score: 0
Accepted
time: 1ms
memory: 3700kb
input:
100 4 6108031 19286908 25394942 3176955 9285008 22463779 28571911 3723535 9831766 23010542 29118549 6900497 13008632 26187364 32295458 232923845 501188579 384201379 372097077 4 10224552 7911590 18136203 14396317 24620812 22307963 32532556 11799831 22024259 19711592 29936037 26196068 36420730 3410773...
output:
13695251424270035 15541348127130361 48952973045836735 12142335032411192 30293462194634291 12848540783195019 25822179494226538 5614415434767934 16211735081331902 15373485218820957 15341405709563082 9399804106735937 19568333204722574 8487402552672659 13716627215369232 16749529678218458 272266786186880...
result:
ok 100 numbers
Test #24:
score: 0
Accepted
time: 3ms
memory: 3768kb
input:
100 4 2084037 1491937 3575957 7477549 9561584 8969466 11053462 3505298 5589173 4997212 7081191 10982734 13066869 12474641 14558730 445016291 98105615 219122114 802214851 4 17225658 16689514 33914952 7061166 24286651 23750592 40976256 11181183 28406717 27870611 45096206 18242321 35467851 34931785 521...
output:
5524296270172206 32530193561370084 13596707860970928 16566679253040825 23201430302382926 13101953988575100 19259814298059875 23089925599096109 28904068166286187 17184348403079203 12715445527254249 20056726728044350 19247988662576289 12749140514437533 26598616300078604 10197292830723210 3404895871655...
result:
ok 100 numbers
Test #25:
score: 0
Accepted
time: 0ms
memory: 3820kb
input:
100 4 19444267 17150615 36594891 11648850 31092936 28799282 48243634 1100815 20545110 18251299 37695557 12749464 32193765 29900035 49344374 163821759 103785017 149079908 679911306 4 18146137 7768946 25915142 15471128 33617357 23240039 41386221 19981362 38127432 27750310 45896492 35452354 53598649 43...
output:
7450441529370550 23332931716556546 27025676362846377 20654228645152901 14085450873938406 13341164465133426 21295434874631510 41511176296865557 41462481624828540 18320491995969469 9802144415114218 34526313622471760 34761253577562387 21818134009257536 25467125838538473 17222562854409516 30751933718589...
result:
ok 100 numbers
Test #26:
score: 0
Accepted
time: 3ms
memory: 3648kb
input:
100 4 9799432 13282524 23081822 4723147 14522690 18005632 27805163 19637954 29437385 32920343 42719828 24361263 34160557 37643678 47442951 745251459 999193495 898693889 260738145 4 225663 12353927 12579454 6414668 6640330 18768563 18994236 5843291 6069064 18197262 18422932 12258015 12483822 24612008...
output:
29939992669323755 9118582028604176 23709427365614498 14963354692145936 29231211077754852 18268963689024040 20273856604394121 5093879705387918 3182566170349885 16465845666473851 25359356053667487 9577165739221913 38201800820028692 28024201764660979 15561841066500038 11257484422361993 7735528207779308...
result:
ok 100 numbers