Submission #1198582

#TimeUsernameProblemLanguageResultExecution timeMemory
1198582nvc2k8Detecting Molecules (IOI16_molecules)C++20
9 / 100
0 ms328 KiB
#include <bits/stdc++.h>
#include "molecules.h"
#define TASK "molecules"
#define INT_LIM (int) 2147483647
#define LL_LIM (long long) 9223372036854775807
#define endl '\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define BIT(i,x) (((i)>>(x))&1)
#define FOR(i,a,b) for(int i = (a); i<=(b); i++)
#define FORD(i,a,b) for(int i = (a); i>=(b); i--)
#define ll long long
#define pii pair<int,int>
using namespace std;
///------------------------------------------///

vector<pii> f;

vector<int> find_subset(int l, int u, vector<int> w)
{
    for (int i = 0; i<(int)w.size(); i++)
    {
        f.pb(mp(w[i], i));
    }
    sort(f.begin(), f.end(), greater<pii>());

    vector<int> ret;
    ll sum = 0;
    for (int i = 0; i<(int)f.size(); i++)
    {
        ll val = f[i].fi;
        if (sum+val>u) continue;

        ret.pb(f[i].se);
        sum+=val;
        if (sum>=l)
        {
            break;
        }
    }

    if (sum>u || sum<l) return vector<int>(0);

    return ret;
}

//signed main()
//{
//    ///--------------------------///
//    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//    if (fopen(TASK".INP","r")!=NULL)
//    {
//        freopen(TASK".INP","r",stdin);
//        freopen(TASK".OUT","w",stdout);
//    }
//    ///--------------------------///
//
//    vector<int> g = find_subset(10, 20, {15, 17, 16, 18});
//
//    for (auto i:g) cout << i << ' ';
//
//
//    return 0;
//}
//
/////------------------------------------------///

Compilation message (stderr)

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...