QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#857550 | #8866. Drying Laundry | asdfsdf# | WA | 424ms | 9344kb | C++17 | 2.2kb | 2025-01-15 20:39:08 | 2025-01-15 20:39:16 |
Judging History
answer
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 303030
#define MAXS 70
#define INF 1'000'000'100'000'000'000
#define bb ' '
#define ln '\n'
#define Ln '\n'
#define MOD 1'000'000'007
#define TC 1
typedef unsigned long long int ull;
int D[MAX];
int S[MAX];
int t1[MAX];
int t2[MAX];
const int BMAX = 10010;
const int LMAX = 300'000;
ull bset[BMAX];
int ans[MAX];
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
int N, Q;
cin >> N >> Q;
int i, j;
for (i = 0; i <= LMAX; i++) ans[i] = 1e9 + 100;
int d, a, b;
vector<tuple<int, int, int>> vt;
for (i = 0; i < N; i++) {
cin >> d >> a >> b;
vt.emplace_back(b, a, d);
}
sort(vt.begin(), vt.end());
ll sumd = 0;
for (i = 1; i <= N; i++) {
tie(t2[i], t1[i], D[i]) = vt[i - 1];
sumd += D[i];
}
if (sumd > 600'000) {
while (Q--) cout << -1 << ln;
return 0;
}
int t1max = 0;
for (i = 1; i <= N; i++) S[i] = S[i - 1] + D[i], t1max = max(t1max, t1[i]);
bset[0] = 1;
if (S[N] <= LMAX) ans[S[N]] = t1max;
for (i = 1; i <= N; i++) {
int d = D[i];
int q = d >> 6;
int r = d & 63;
for (j = BMAX - 1; j >= 0; j--) {
if (j + q < BMAX) bset[j + q] |= (bset[j] << r);
if (j + q + 1 < BMAX && r) bset[j + q + 1] |= (bset[j] >> (64 - r));
}
int s = S[i];
int m = s / 2;
int mv = s;
vector<int> rv;
for (j = (m / 64) + 1; j < BMAX; j++) {
if (bset[j]) {
rv.push_back(j);
break;
}
}
for (j = (m / 64) - 1; j >= 0; j--) {
if (bset[j]) {
rv.push_back(j);
break;
}
}
if (bset[m / 64]) rv.push_back(m / 64);
for (auto c : rv) {
for (j = 0; j < 64; j++) {
if (bset[c] >> j & 1) {
int loc = c * 64 + j;
mv = min(mv, max(loc, s - loc));
}
}
}
if (mv + S[N] - S[i] <= LMAX) ans[mv + S[N] - S[i]] = min(ans[mv + S[N] - S[i]], max(t1max, t2[i]));
}
for (i = 1; i <= LMAX; i++) ans[i] = min(ans[i], ans[i - 1]);
while (Q--) {
int l;
cin >> l;
if (ans[l] >= 1e9 + 10) cout << -1 << ln;
else cout << ans[l] << ln;
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 424ms
memory: 8464kb
input:
30000 300000 2 255945072 661001220 2 68592698 870026391 2 297602072 943696446 2 423786358 574645263 2 178914703 647767179 2 198609024 717883631 2 167020579 942479667 2 63119081 995866587 2 347306369 881413517 2 58674847 601956876 2 110801873 707995015 2 155453326 765668358 2 438060979 649128264 2 20...
output:
-1 780386172 -1 882630795 -1 -1 694190157 535268040 -1 -1 822780178 867163401 -1 -1 787724542 -1 -1 843406425 -1 608088477 -1 678487355 611519637 956002698 -1 -1 691131846 -1 -1 812320879 -1 677850117 -1 537706551 -1 893747900 786791412 -1 -1 715094556 -1 810021220 724602450 950838618 686685989 -1 -...
result:
ok 300000 lines
Test #2:
score: 0
Accepted
time: 422ms
memory: 8412kb
input:
30000 300000 2 413765174 786945255 2 24450079 633888170 2 156975003 952655942 2 379103955 736927310 2 51344414 628485891 2 157726253 856648277 2 409188889 776741476 2 330057403 503154132 2 65713572 607924429 2 19022370 553222365 2 110606093 900891955 2 66002336 647224103 2 87024669 623977746 2 20830...
output:
877900850 980826970 920400419 -1 780921851 548809154 846536024 657895078 560285125 605878996 -1 -1 813471789 935323463 745605611 -1 519320735 -1 702393535 -1 527145090 -1 -1 649035142 820250008 787597619 818808379 517386799 -1 -1 -1 -1 830698654 -1 929488761 738312393 582232423 816391982 827606857 -...
result:
ok 300000 lines
Test #3:
score: -100
Wrong Answer
time: 422ms
memory: 9344kb
input:
30000 300000 2 144047749 882189958 2 83144441 640133172 2 473201190 758221024 2 38439990 824132397 2 325418384 815093634 2 168394481 996371307 2 431368790 704820404 2 87398772 861995425 2 346199699 839918228 2 324092843 809028436 2 140500417 642886267 2 205402464 693087806 2 35470561 592985908 2 339...
output:
695687446 750305729 876831601 872403755 -1 731416606 805827927 903848489 737429622 -1 -1 -1 -1 -1 -1 835868937 994338808 -1 -1 585302773 925693790 716121968 927078747 -1 690840084 -1 -1 -1 656381891 619730684 716347318 557503192 -1 680501611 -1 -1 -1 706636370 723191258 -1 -1 767780575 926847838 521...
result:
wrong answer 21755th lines differ - expected: '500348820', found: '500342777'