Submission #1068853

#TimeUsernameProblemLanguageResultExecution timeMemory
1068853kiethm07Detecting Molecules (IOI16_molecules)C++11
9 / 100
1 ms604 KiB
#include <bits/stdc++.h> #define pii pair<int,int> #define iii pair<int,pii> #define fi first #define se second #define vi vector<int> #define vii vector<pii> #define pb(i) push_back(i) #define all(x) x.begin(),x.end() #define TEXT "a" using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; const int inf = 1e9 + 7; const ld eps = 1e-8; const double pi = acos(-1); vector<int> find_subset(int l,int r,vector<int> w){ int n = w.size(); vector<pii> a(n); for (int i = 0; i < n; i++){ a[i] = pii(w[i],i); } sort(all(a)); ll sum = 0; for (int i = 0; i < n; i++){ sum += a[i].fi - a[0].fi; } vector<int> res; for (ll x = 1; x <= n; x++){ ll c = l - x * a[0].fi; ll d = r - x * a[0].fi; if (d < 0) break; if (sum < c) continue; ll cur = 0; for (int j = n - 1; j >= 0; j--){ int p = a[j].fi - a[0].fi; if (cur + p > d) continue; cur += p; res.push_back(a[j].se); if (res.size() == x) break; } if (res.size() != x) return {}; break; } return res; } // //int main(){ // int l = 15,r = 17; // vector<int> w = {6,8,8,7}; // vi v = find_subset(l,r,w); // for (int i : v) cout << i << " "; cout << "\n"; // l = 14, r = 15; // w = {5,5,6,6}; // v = find_subset(l,r,w); // for (int i : v) cout << i << " "; cout << "\n"; // l = 10, r = 20; // w = {15,17,16,18}; // v = find_subset(l,r,w); // for (int i : v) cout << i << " "; cout << "\n"; // return 0; //}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:48:28: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   48 |             if (res.size() == x) break;
      |                 ~~~~~~~~~~~^~~~
molecules.cpp:50:24: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   50 |         if (res.size() != x) return {};
      |             ~~~~~~~~~~~^~~~
#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...