#include <bits/stdc++.h>
#include <molecules.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;
vi find_subset(int d, int u, vi w){
int n = w.size();
vector<pair<ll,int>> w2(n);
FOR(i,n) w2[i].f = w[i];
FOR(i,n) w2[i].s = i+1;
sort(all(w2));
int l = 0, r = 0;
ll total = 0;
for(; l < n; l++){
if(r < l){
total = 0;
r = l;
}else if(l != 0) total -= w2[l-1].f;
for(; (r<n && total+w2[r].f <= u); r++) total += w2[r].f;
if(total >= d) break;
}
if(l == r){
vi ans;
return ans;
}else{
vi ans(r-l);
FOR(i,r-l) ans[i] = w2[l+i].s;
return ans;
}
}
//void testf(){
// int n,l,u;
// cin >> n >> l >> u;
// int w[n]; FOR(i,n) cin >> w[i];
// int ans[n];
// int m = find_subset(l,u,w,n,ans);
// cout << m << "\n";
// FOR(i,m) cout << ans[i] << " ";
// cout << "\n";
//}
//
//int main()
//{
// ios_base::sync_with_stdio(0); cin.tie(0);
//// testf();
// return 0;
//}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
OK (n = 12, answer = YES) |
2 |
Correct |
0 ms |
256 KB |
OK (n = 12, answer = YES) |
3 |
Correct |
0 ms |
256 KB |
OK (n = 12, answer = NO) |
4 |
Correct |
1 ms |
288 KB |
OK (n = 12, answer = NO) |
5 |
Incorrect |
1 ms |
256 KB |
sum of weights should be in [290..300] but it is 301 |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |