Submission #283135

# Submission time Handle Problem Language Result Execution time Memory
283135 2020-08-25T10:25:44 Z sofapuden Detecting Molecules (IOI16_molecules) C++14
0 / 100
1 ms 384 KB
#include <bits/stdc++.h>
#include "molecules.h"

using namespace std;
typedef long long ll;

vector<int> find_subset(int l, int u, vector<int> w) {
	ll n = w.size();
	ll l2 = l;
	ll u2 = u;
	vector<pair<ll,int>> v(n);
	vector<int> out;
	ll sum = 0LL;
	for(int i = 0; i < n; ++i){
		sum+=(ll)w[i];
		if(sum > u2)break;
	}
	if(sum <= u2 && sum >= l2){
		out.resize(n);
		iota(out.begin(),out.end(),0);
		return out;
	}
		
	for(int i = 0; i < n; ++i){
		v[i].first =  (ll)w[i];
		v[i].second = i;
	}
	sort(v.begin(), v.end());
	ll le = 0, ri = n-1;
	sum = v[n-1].first;
	while(sum < l2 && le < ri){
		sum+=v[--ri].first;
	}
	while(sum > u2 && le < ri && le < n-ri){
		sum-=v[n-le-1].first;
		sum+=v[le].first;
		le++;
		cout << sum << endl;
	}
	if(sum <= u2 && sum >= l2){
		for(int i = 0; i < le; ++i){
			out.push_back(v[i].second);
		}
		for(int i = n-1-le; i>= ri; --i){
			out.push_back(v[i].second);
		}
		return out;
	}	
	
    return vector<int>(0);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Correct 0 ms 256 KB OK (n = 1, answer = YES)
4 Correct 1 ms 256 KB OK (n = 2, answer = YES)
5 Correct 0 ms 256 KB OK (n = 2, answer = YES)
6 Correct 1 ms 256 KB OK (n = 3, answer = YES)
7 Correct 1 ms 256 KB OK (n = 3, answer = YES)
8 Correct 1 ms 256 KB OK (n = 3, answer = YES)
9 Correct 1 ms 384 KB OK (n = 3, answer = YES)
10 Correct 0 ms 256 KB OK (n = 3, answer = YES)
11 Correct 0 ms 256 KB OK (n = 3, answer = YES)
12 Correct 1 ms 256 KB OK (n = 3, answer = YES)
13 Incorrect 1 ms 256 KB Secret is incorrect!
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Correct 0 ms 256 KB OK (n = 1, answer = YES)
4 Correct 1 ms 256 KB OK (n = 2, answer = YES)
5 Correct 0 ms 256 KB OK (n = 2, answer = YES)
6 Correct 1 ms 256 KB OK (n = 3, answer = YES)
7 Correct 1 ms 256 KB OK (n = 3, answer = YES)
8 Correct 1 ms 256 KB OK (n = 3, answer = YES)
9 Correct 1 ms 384 KB OK (n = 3, answer = YES)
10 Correct 0 ms 256 KB OK (n = 3, answer = YES)
11 Correct 0 ms 256 KB OK (n = 3, answer = YES)
12 Correct 1 ms 256 KB OK (n = 3, answer = YES)
13 Incorrect 1 ms 256 KB Secret is incorrect!
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Correct 0 ms 256 KB OK (n = 1, answer = YES)
4 Correct 1 ms 256 KB OK (n = 2, answer = YES)
5 Correct 0 ms 256 KB OK (n = 2, answer = YES)
6 Correct 1 ms 256 KB OK (n = 3, answer = YES)
7 Correct 1 ms 256 KB OK (n = 3, answer = YES)
8 Correct 1 ms 256 KB OK (n = 3, answer = YES)
9 Correct 1 ms 384 KB OK (n = 3, answer = YES)
10 Correct 0 ms 256 KB OK (n = 3, answer = YES)
11 Correct 0 ms 256 KB OK (n = 3, answer = YES)
12 Correct 1 ms 256 KB OK (n = 3, answer = YES)
13 Incorrect 1 ms 256 KB Secret is incorrect!
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Correct 0 ms 256 KB OK (n = 1, answer = YES)
4 Correct 1 ms 256 KB OK (n = 2, answer = YES)
5 Correct 0 ms 256 KB OK (n = 2, answer = YES)
6 Correct 1 ms 256 KB OK (n = 3, answer = YES)
7 Correct 1 ms 256 KB OK (n = 3, answer = YES)
8 Correct 1 ms 256 KB OK (n = 3, answer = YES)
9 Correct 1 ms 384 KB OK (n = 3, answer = YES)
10 Correct 0 ms 256 KB OK (n = 3, answer = YES)
11 Correct 0 ms 256 KB OK (n = 3, answer = YES)
12 Correct 1 ms 256 KB OK (n = 3, answer = YES)
13 Incorrect 1 ms 256 KB Secret is incorrect!
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Correct 0 ms 256 KB OK (n = 1, answer = YES)
4 Correct 1 ms 256 KB OK (n = 2, answer = YES)
5 Correct 0 ms 256 KB OK (n = 2, answer = YES)
6 Correct 1 ms 256 KB OK (n = 3, answer = YES)
7 Correct 1 ms 256 KB OK (n = 3, answer = YES)
8 Correct 1 ms 256 KB OK (n = 3, answer = YES)
9 Correct 1 ms 384 KB OK (n = 3, answer = YES)
10 Correct 0 ms 256 KB OK (n = 3, answer = YES)
11 Correct 0 ms 256 KB OK (n = 3, answer = YES)
12 Correct 1 ms 256 KB OK (n = 3, answer = YES)
13 Incorrect 1 ms 256 KB Secret is incorrect!
14 Halted 0 ms 0 KB -