Submission #1289278

#TimeUsernameProblemLanguageResultExecution timeMemory
1289278hssaan_arifDetecting Molecules (IOI16_molecules)C++20
9 / 100
2 ms348 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> w1) { vector<pair<int,int>> w; for (int i=0; i<w1.size() ; i++){ w.pb({w1[i],i}); } int su = 0 , ls = w.size()-1; // cout << ls << endl; vector<int> ans; sort(w.rbegin(),w.rend()); for (int i=0 ; i <w.size() ; i++){ su += w[i].fi; ans.pb(w[i].se); if (l <= su && su <= u){ return ans; } if (su > u){ int f = i+1; while(f--){ su -= w[i].fi; ans.pop_back(); su += w[ls].fi; ans.pb(w[ls].se); i--; ls--; if (l <= su && su <= u){ return ans; } } return vector<int>(0); } } return vector<int>(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...