#include<bits/stdc++.h>
#include "molecules.h"
using namespace std;
vector<int> find_subset(int l, int d, vector<int> v){
int n = v.size();
int pref[n+1];
pref[0] = v[0]; pref[n] = (1 << 31)+5;
int poc = 0, kraj = 1;
for(int i=1; i<n; i++) pref[i] = pref[i-1] + v[i];
while(kraj <= n){
int sum = pref[kraj-1];
if (poc > 0) sum -= pref[poc-1];
cout << sum << " | " << poc << " " << kraj << endl;
if (sum >= l and sum <= d) return {poc, kraj-1};
else if (sum > d) poc++;
else kraj++;
}
return {};
}
/*
int main(){
int n, m; vector<int> l{1, 2, 3, 4, 5}; cin >> n >> m;
for(int i=0; i<5; i++) cin >> l[i];
vector<int> tmp = find_subset(n, m, l); cout << tmp[0] << " " << tmp[1]; return 0;
}*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Secret is incorrect! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
300 KB |
Secret is incorrect! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Secret is incorrect! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Secret is incorrect! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Secret is incorrect! |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Secret is incorrect! |
2 |
Halted |
0 ms |
0 KB |
- |