Submission #171277

# Submission time Handle Problem Language Result Execution time Memory
171277 2019-12-28T07:11:07 Z Nodir_Bobiev Detecting Molecules (IOI16_molecules) C++14
0 / 100
2 ms 256 KB
# include <bits/stdc++.h>
# define FILE

using namespace std;


vector < int > find_subset( int l, int u, vector < int > w ){
	int n = w.size();
	pair < int, int > pr[n];
	for( int i = 0; i < n; i ++ )
		pr[i] = make_pair( w[i], i );
	
	sort( pr, pr+n );

	int ll = 0, rr = 1;
	int sum = pr[ll].first;
	vector < int > answers;

	while( rr < n ){
		if( sum > u ){
			sum -= pr[ll++].first;
			if( ll >= rr ){
				return answers;
			}
		}
		if( l <= sum && sum <= u ){
			for( int i = ll; i < rr; i ++ ){
				answers.push_back( pr[i].second );
			}
			return answers;
		}
		sum += pr[rr++].first;
	}
	if( sum > u ){
		sum -= pr[ll].first;
		ll++;
	}
	for( int i = ll; i < rr; i ++ )
		answers.push_back( i );
	return answers;
}
/*
int main(){

    # ifdef FILE
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif
    int n, l, u;
    cin >> n >> l >> u;
    vector < int > w(n);
    for( int i = 0; i < n; i ++ ){
    	cin >> w[i];
    }

    vector < int > ans = find_subset( l, u, w );
    for( auto c: ans ){
    	cout << c << ' ';
    }cout << endl;
    return 0;
}	
*/

# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 12, answer = YES)
2 Correct 2 ms 256 KB OK (n = 12, answer = YES)
3 Incorrect 0 ms 256 KB sum of weights should be in [307..317] but it is 306
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -