Submission #305903

# Submission time Handle Problem Language Result Execution time Memory
305903 2020-09-24T04:51:06 Z talant117408 Detecting Molecules (IOI16_molecules) C++17
0 / 100
1 ms 384 KB
#include "molecules.h"

#include <bits/stdc++.h>

using namespace std;
/*
vector <int> find_subset(int l, int u, vector <int> w);
int main() {
    int n, l, u;
    assert(3 == scanf("%d %d %d", &n, &l, &u));
    std::vector<int> w(n);
    for (int i = 0; i < n; i++)
        assert(1 == scanf("%d", &w[i]));
    std::vector<int> result = find_subset(l, u, w);
    
    printf("%d\n", (int)result.size());
    for (int i = 0; i < (int)result.size(); i++)
        printf("%d%c", result[i], " \n"[i == (int)result.size() - 1]);
}

*/
vector <int> find_subset(int l, int r, vector <int> w){
    int n = w.size();
    vector <pair<int, int>> pref(n);
    for(int i = 0; i < n; i++){
        pref[i] = {w[i], i};
    }
    sort(pref.begin(), pref.end());
    int sum = 0;
    
    for(int i = 0, j = 0; j < n; j++){
        sum += pref[j].first;
        if(sum > r){
            while(sum > r){
                sum -= pref[i++].first;
            }
        }
        if(sum >= l){
            vector <int> inds;
            for(int k = i; k <= j; k++){
                inds.push_back(pref[k].second+1);
            }
            return inds;
        }
    }
    
    return vector <int> (0);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 1 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 384 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 12, answer = YES)
2 Correct 1 ms 256 KB OK (n = 12, answer = YES)
3 Correct 1 ms 256 KB OK (n = 12, answer = NO)
4 Correct 1 ms 256 KB OK (n = 12, answer = NO)
5 Incorrect 1 ms 384 KB sum of weights should be in [290..300] but it is 301
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 1 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 384 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 1 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 384 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 1 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 384 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 1 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 384 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -