Submission #1062618

# Submission time Handle Problem Language Result Execution time Memory
1062618 2024-08-17T09:07:29 Z TsotneSV Detecting Molecules (IOI16_molecules) C++17
10 / 100
1 ms 348 KB
#pragma once

#include <bits/stdc++.h>
using namespace std;

/* /\_/\
  (= ._.)
  / >  \>
*/

#define fi first
#define se second


vector<int> find_subset(int l, int u, vector<int> w) {
    
    int n = w.size();

    pair<int,int> A[n];

    for(int i=0;i<n;i++) A[i] = {w[i],i};

    sort(A,A+n);

    int lo = 0,hi = 0; long long sum = 0;

    while(hi < n) {

        sum += A[hi++].fi;

        while(lo < hi-1 and sum > u) sum -= A[lo++].fi;

        if(sum >= l) {

            vector<int> ret(hi - lo);

            for(int i=lo;i<hi;i++) ret[i-lo] = A[i].se;
            return ret;
        }

    }
    
    return vector<int>(0);
}

Compilation message

molecules.cpp:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Incorrect 1 ms 348 KB sum of weights should be in [10..12] but it is 13
3 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 344 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 1 ms 348 KB OK (n = 12, answer = YES)
7 Correct 0 ms 348 KB OK (n = 12, answer = YES)
8 Correct 1 ms 344 KB OK (n = 12, answer = YES)
9 Correct 0 ms 348 KB OK (n = 6, answer = YES)
10 Correct 0 ms 344 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 1 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 0 ms 348 KB OK (n = 1, answer = NO)
2 Incorrect 1 ms 348 KB sum of weights should be in [10..12] but it is 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Incorrect 1 ms 348 KB sum of weights should be in [10..12] but it is 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Incorrect 1 ms 348 KB sum of weights should be in [10..12] but it is 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB OK (n = 1, answer = NO)
2 Incorrect 1 ms 348 KB sum of weights should be in [10..12] but it is 13
3 Halted 0 ms 0 KB -