Submission #1083954

# Submission time Handle Problem Language Result Execution time Memory
1083954 2024-09-04T15:52:44 Z mindiyak Detecting Molecules (IOI16_molecules) C++14
0 / 100
1 ms 348 KB
#include "molecules.h"
#include <algorithm>

#define F first
#define S second

using namespace std;
 
vector<int> find_subset(int l, int u, vector<int> w) {
    int n = w.size();
    vector<pair<int,int>> arr(n);
    for(int i=0;i<n;i++)arr[i] = {w[i],i};
    sort(arr.begin(),arr.end());

    vector<int> pre(n+1,0);
    for(int i=1;i<=n;i++)pre[i] = pre[i-1] + arr[i-1].F;



    int a = 0,b = 0;
    while(b<n && a<n){
        if(pre[b] - pre[a] >= l && pre[b] - pre[a] <= u){
            break;
        }
        else if(pre[b] - pre[a] > u)a++;
        else b++;
    }

    if(b == n || a == n || pre[b]-pre[a] < l || pre[b] - pre[a] > u)return vector<int>();

    vector<int> ans;
    for(int i=a+1;i<=b;i++)ans.push_back(arr[i].S);
    return ans;
}
# 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 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 344 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 Incorrect 0 ms 348 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 0 ms 344 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 344 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 344 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 344 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 -