QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#129378 | #2779. Detecting Molecules | valerikk# | 9 | 0ms | 4092kb | C++17 | 1.5kb | 2023-07-22 17:36:20 | 2024-07-04 00:52:29 |
Judging History
answer
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
namespace {
typedef long long ll;
const int N = 2e5 + 7;
int n;
ll l, u;
pair<int, int> a[N];
}
vector<int> find_subset(int grdl, int grdu, vector<int> grdw) {
l = grdl;
u = grdu;
n = grdw.size();
for (int i = 0; i < n; ++i) {
a[i].first = grdw[i];
a[i].second = i;
}
sort(a, a + n);
ll mnsum = 0, mxsum = 0;
for (int k = 1; k <= n; ++k) {
mnsum += a[k - 1].first;
mxsum += a[n - k].first;
if (mnsum >= l && mnsum <= u) {
vector<int> ret;
for (int i = 0; i < k; ++i) {
ret.push_back(a[i].second);
}
return ret;
}
if (mxsum >= l && mxsum <= u) {
vector<int> ret;
for (int i = 0; i < k; ++i) {
ret.push_back(a[i].second);
}
return ret;
}
if (mnsum > u || mxsum < l) {
continue;
}
ll sum = 0;
for (int i = 0; i < k - 1; ++i) {
sum += a[i].first;
}
for (int i = k - 1; i >= 0; --i) {
int l1 = i - 1, r1 = n - k + i + 1;
while (r1 - l1 > 1) {
int m1 = (l1 + r1) / 2;
if (sum + a[m1].first < l) {
l1 = m1;
} else {
r1 = m1;
}
}
if (r1 != n - k + i + 1 && sum + a[r1].first >= l && sum + a[r1].first <= u) {
vector<int> ret;
for (int j = 0; j < i; ++j) {
ret.push_back(a[j].second);
}
for (int j = n - k + i + 1; j < n; ++j) {
ret.push_back(a[j].second);
}
ret.push_back(a[r1].second);
return ret;
}
if (i != 0) {
sum -= a[i].first;
sum += a[n - k + i].first;
}
}
}
return {};
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 9
Accepted
Test #1:
score: 9
Accepted
time: 0ms
memory: 3828kb
input:
1 10 12 9
output:
14e047d7a2907b9034950b074822b302 0
result:
ok OK (n = 1, answer = NO)
Test #2:
score: 0
Accepted
time: 0ms
memory: 3832kb
input:
1 10 12 13
output:
14e047d7a2907b9034950b074822b302 0
result:
ok OK (n = 1, answer = NO)
Test #3:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
1 10 10 10
output:
14e047d7a2907b9034950b074822b302 1 0
result:
ok OK (n = 1, answer = YES)
Test #4:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
2 100 100 50 50
output:
14e047d7a2907b9034950b074822b302 2 0 1
result:
ok OK (n = 2, answer = YES)
Test #5:
score: 0
Accepted
time: 0ms
memory: 3828kb
input:
2 100 100 100 100
output:
14e047d7a2907b9034950b074822b302 1 0
result:
ok OK (n = 2, answer = YES)
Test #6:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
3 5 5 5 5 5
output:
14e047d7a2907b9034950b074822b302 1 0
result:
ok OK (n = 3, answer = YES)
Test #7:
score: 0
Accepted
time: 0ms
memory: 3736kb
input:
3 15 15 5 5 5
output:
14e047d7a2907b9034950b074822b302 3 0 1 2
result:
ok OK (n = 3, answer = YES)
Test #8:
score: 0
Accepted
time: 0ms
memory: 4084kb
input:
3 10 10 5 5 5
output:
14e047d7a2907b9034950b074822b302 2 0 1
result:
ok OK (n = 3, answer = YES)
Test #9:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
3 10 15 5 5 5
output:
14e047d7a2907b9034950b074822b302 2 0 1
result:
ok OK (n = 3, answer = YES)
Test #10:
score: 0
Accepted
time: 0ms
memory: 4052kb
input:
3 5 15 5 5 5
output:
14e047d7a2907b9034950b074822b302 1 0
result:
ok OK (n = 3, answer = YES)
Test #11:
score: 0
Accepted
time: 0ms
memory: 4088kb
input:
3 1 5 5 5 5
output:
14e047d7a2907b9034950b074822b302 1 0
result:
ok OK (n = 3, answer = YES)
Test #12:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
3 11 15 5 5 5
output:
14e047d7a2907b9034950b074822b302 3 0 1 2
result:
ok OK (n = 3, answer = YES)
Test #13:
score: 0
Accepted
time: 0ms
memory: 4092kb
input:
3 6 9 5 5 5
output:
14e047d7a2907b9034950b074822b302 0
result:
ok OK (n = 3, answer = NO)
Test #14:
score: 0
Accepted
time: 0ms
memory: 3740kb
input:
3 1 9 5 5 5
output:
14e047d7a2907b9034950b074822b302 1 0
result:
ok OK (n = 3, answer = YES)
Test #15:
score: 0
Accepted
time: 0ms
memory: 3808kb
input:
3 14 19 5 5 5
output:
14e047d7a2907b9034950b074822b302 3 0 1 2
result:
ok OK (n = 3, answer = YES)
Test #16:
score: 0
Accepted
time: 0ms
memory: 3860kb
input:
3 1 4 5 5 5
output:
14e047d7a2907b9034950b074822b302 0
result:
ok OK (n = 3, answer = NO)
Test #17:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
3 16 20 5 5 5
output:
14e047d7a2907b9034950b074822b302 0
result:
ok OK (n = 3, answer = NO)
Test #18:
score: 0
Accepted
time: 0ms
memory: 3688kb
input:
100 971 971 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 83 ...
output:
14e047d7a2907b9034950b074822b302 0
result:
ok OK (n = 100, answer = NO)
Test #19:
score: 0
Accepted
time: 0ms
memory: 3804kb
input:
100 63 63 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
output:
14e047d7a2907b9034950b074822b302 63 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
result:
ok OK (n = 100, answer = YES)
Test #20:
score: 0
Accepted
time: 0ms
memory: 3876kb
input:
100 150 150 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
output:
14e047d7a2907b9034950b074822b302 0
result:
ok OK (n = 100, answer = NO)
Subtask #2:
score: 0
Wrong Answer
Dependency #1:
100%
Accepted
Test #21:
score: 10
Accepted
time: 0ms
memory: 3780kb
input:
4 14 15 5 5 6 6
output:
14e047d7a2907b9034950b074822b302 0
result:
ok OK (n = 4, answer = NO)
Test #22:
score: 0
Accepted
time: 0ms
memory: 3772kb
input:
12 302 304 50 50 50 50 50 50 51 51 51 51 51 51
output:
14e047d7a2907b9034950b074822b302 6 0 1 2 3 11 6
result:
ok OK (n = 12, answer = YES)
Test #23:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
12 302 304 50 50 50 50 50 50 51 51 51 51 51 51
output:
14e047d7a2907b9034950b074822b302 6 0 1 2 3 11 6
result:
ok OK (n = 12, answer = YES)
Test #24:
score: 0
Accepted
time: 0ms
memory: 4084kb
input:
12 307 317 50 50 50 50 50 50 51 51 51 51 51 51
output:
14e047d7a2907b9034950b074822b302 0
result:
ok OK (n = 12, answer = NO)
Test #25:
score: 0
Accepted
time: 0ms
memory: 4080kb
input:
12 290 299 50 50 50 50 50 50 51 51 51 51 51 51
output:
14e047d7a2907b9034950b074822b302 0
result:
ok OK (n = 12, answer = NO)
Test #26:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
12 290 300 50 50 50 50 50 50 51 51 51 51 51 51
output:
14e047d7a2907b9034950b074822b302 6 0 1 2 3 4 5
result:
ok OK (n = 12, answer = YES)
Test #27:
score: -10
Wrong Answer
time: 0ms
memory: 3800kb
input:
12 306 310 50 50 50 50 50 50 51 51 51 51 51 51
output:
14e047d7a2907b9034950b074822b302 6 0 1 2 3 4 5
result:
wrong answer sum of weights should be in [306..310] but it is 300
Subtask #3:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%
Subtask #5:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%
Subtask #6:
score: 0
Skipped
Dependency #1:
100%
Accepted
Dependency #2:
0%