Submission #1004059

# Submission time Handle Problem Language Result Execution time Memory
1004059 2024-06-21T03:48:36 Z spensa Detecting Molecules (IOI16_molecules) C++17
0 / 100
0 ms 432 KB
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(int i=(signed)(a); i<=(signed)(b); i++)
#define F0R(i, a) for(int i=(signed)(0); i<(signed)(a); i++)

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    vector<pair<ll, int>> v;
    int N = w.size();
    ll tsm = 0LL;
    FOR(i, 0, N-1){
        v.pb(mp((ll) w[i], i));
        tsm += w[i];
    }

    if(tsm>l) return vector<int>(0);


    sort(v.begin(), v.end());
    int a, b;
    a = b = 0;
    ll cur = v[0].first;
    
    vector<int> ans;
    if(cur>u) return vector<int>(0);
    if(cur>=l){
        ans.pb(v[0].second);
        return ans;
    }

    while(b<N){
        b++;
        cur += v[b].first;
        if(cur>=l && cur<=u){
            break;
        }
        while(cur>u){
            cur-=v[a].first;
            a++;
        }
    }

    tsm = 0;
    for(int i=a; i<=b; i++){
        tsm += v[i].first;
        ans.pb(v[i].second);
    }
    if(tsm>=l && tsm<=u) return ans;
    return vector<int>(0);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 0 ms 348 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Incorrect 0 ms 432 KB Contestant can not find answer, jury can
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 0 ms 348 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Incorrect 0 ms 432 KB Contestant can not find answer, jury can
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 0 ms 348 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Incorrect 0 ms 432 KB Contestant can not find answer, jury can
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 0 ms 348 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Incorrect 0 ms 432 KB Contestant can not find answer, jury can
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 0 ms 348 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Incorrect 0 ms 432 KB Contestant can not find answer, jury can
6 Halted 0 ms 0 KB -