Submission #1289272

#TimeUsernameProblemLanguageResultExecution timeMemory
1289272hssaan_arifDetecting Molecules (IOI16_molecules)C++20
0 / 100
1 ms332 KiB
#include <bits/stdc++.h>
#include "molecules.h"

using namespace std;

#define endl "\n"
#define pb push_back
// #define int long long
#define fi first
#define se second

const int N = 3e5 + 5, M = 1e9 + 7, LG = 20;

int n;

vector<int> find_subset(int l, int u, vector<int> w) {
    int su = 0 , ls = w.size()-1;
    vector<int> ans;
    sort(w.rbegin(),w.rend());
    for (int i=0 ; i <w.size() ; i++){
        su += w[i];
        ans.pb(w[i]);
        if (l <= su && su <= u){
            return ans;
        }
        if (su > u){
            int f = i+1;
            while(f--){
                su -= w[i];
                ans.pop_back();
                su += w[ls];
                ans.pb(w[ls]);
                i--;
                ls--;
                if (l <= su && su <= u){
                    return ans;
                }
            }
            return vector<int>(0);
        }
    }
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:42:1: warning: control reaches end of non-void function [-Wreturn-type]
   42 | }
      | ^
molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...