Submission #990393

#TimeUsernameProblemLanguageResultExecution timeMemory
990393hashimDetecting Molecules (IOI16_molecules)C++14
69 / 100
32 ms5716 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define pf push_front
#define ep emplace_back
#define ef emplace_front
// #define int long long
// #define ld long double
// #define stoi stoll
#define all(ls) ls.begin(),ls.end()
#define allr(ls) ls.rbegin(),ls.rend()
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
 
using namespace std; 

using namespace __gnu_pbds;
 
template<typename type>using ordered_set=tree<type,null_type,less<type>,rb_tree_tag,tree_order_statistics_node_update>;
template<typename type>using ordered_multiset=tree<type,null_type,less_equal<type>,rb_tree_tag,tree_order_statistics_node_update>;
 
int sum(int ls[],int n){int sum=0;for(int i=0;i<n;i++)sum+=ls[i];return sum;}
 
int count(string str,string word){regex regex_word(word);sregex_iterator it(all(str),regex_word);sregex_iterator end;int count=0;while(it!=end){count++;it++;}return count;}

vector<int>find_subset(int l,int u,vector<int>w){
  pair<int,int> ls[w.size()];
  for(int i=0;i<w.size();i++){
    ls[i]={w[i],i};
  }
  sort(ls,ls+w.size());
  deque<int>ans;
  int i=0,j=0,sum=0;
  while(i<w.size() and j<w.size()){
    if(sum<u){
      sum+=ls[i].first;
      ans.pb(ls[i].second);
      i++;
    }
    if(sum>u){
      sum-=ls[j].first;
      ans.pop_front();
      j++;
    }
    if(l<=sum and sum<=u){
      vector<int>arr;
      reverse(all(ans));
      for(auto i:ans)
        arr.pb(i);
      return arr;
    }
  }
  return {};
}

// void solve(){
//   for(aut
// }

// signed main(){
//   ios_base::sync_with_stdio(0);
//   cin.tie(nullptr); 
//   cout.tie(nullptr);
//   int t=1;
//   // cin>>t;
//   while(t--)
//     solve();
// }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:31:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |   for(int i=0;i<w.size();i++){
      |               ~^~~~~~~~~
molecules.cpp:37:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   while(i<w.size() and j<w.size()){
      |         ~^~~~~~~~~
molecules.cpp:37:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   while(i<w.size() and j<w.size()){
      |                        ~^~~~~~~~~
#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...