Submission #1062105

# Submission time Handle Problem Language Result Execution time Memory
1062105 2024-08-16T19:05:49 Z Hectorungo_18 Detecting Molecules (IOI16_molecules) C++14
10 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;

mt19937 gnd(time(nullptr));

// #define int long long
vector<int> find_subset(int l, int r, vector<int> w){
    int n = w.size();
    vector<pair<int, int>> v(n);
    for(int i = 0; i < n; i++){
        v[i]={w[i], i};
    }
    sort(v.begin(), v.end());

    queue<pair<int, int>> sol;
    int aux = 0;
    vector<int> ba, bb;
    for(int i = 0; i < n; i++){
        if(v[i].first <= r && v[i].first >= l){
            while(sol.size()) sol.pop();
            sol.push(v[i]);
            break;
        }
        if(v[i].first > r) break;
        while(aux+v[i].first > r){
            
            ba.push_back(sol.front().first);
            bb.push_back(sol.front().second);
            aux-=sol.front().first;
            sol.pop();
        }
        aux+=v[i].first;
        sol.push(v[i]);
        if(aux >= l) break;
        int fal = l-aux;
        auto it = lower_bound(ba.begin(), ba.end(), fal);
        if(it == ba.end()) continue;
        int pos = it-ba.begin();
        if(aux+ba[pos] <= r){
            aux+=ba[pos];
            sol.push({ba[pos], bb[pos]});
            break;
        }
    }
    if(aux < l || aux > r){
        while(sol.size()) sol.pop();
    }

    vector<int> ans;
    while(sol.size()){
        ans.push_back(sol.front().second);
        sol.pop();
    }

    if(ans.size()) sort(ans.begin(), ans.end());

    return ans;
    
    
    
    
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB OK (n = 12, answer = YES)
2 Correct 0 ms 348 KB OK (n = 12, answer = YES)
3 Correct 0 ms 348 KB OK (n = 12, answer = NO)
4 Correct 0 ms 348 KB OK (n = 12, answer = NO)
5 Correct 0 ms 348 KB OK (n = 12, answer = YES)
6 Correct 0 ms 348 KB OK (n = 12, answer = YES)
7 Correct 0 ms 348 KB OK (n = 12, answer = YES)
8 Correct 1 ms 348 KB OK (n = 12, answer = YES)
9 Correct 0 ms 348 KB OK (n = 6, answer = YES)
10 Correct 0 ms 348 KB OK (n = 12, answer = YES)
11 Correct 0 ms 348 KB OK (n = 100, answer = NO)
12 Correct 0 ms 348 KB OK (n = 100, answer = YES)
13 Correct 0 ms 348 KB OK (n = 100, answer = NO)
14 Correct 0 ms 348 KB OK (n = 100, answer = YES)
15 Correct 0 ms 348 KB OK (n = 100, answer = YES)
16 Correct 0 ms 348 KB OK (n = 100, answer = YES)
17 Correct 0 ms 348 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -