Submission #145078

# Submission time Handle Problem Language Result Execution time Memory
145078 2019-08-18T17:21:48 Z Nightlight Detecting Molecules (IOI16_molecules) C++14
0 / 100
1000 ms 376 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;

vector<int> ans;

vector<int> find_subset(int l, int u, vector<int> w) {
  sort(w.begin(), w.end());
  int N = w.size();
  long long sum = w[0];
  int low = N-1, up = N-1;
  while((sum < l || sum > u) && low >= 0){
    while(sum < l && up >= low){
      up--;
      sum += w[up];
    }
    while(sum > u && low >= 0){
      sum -= w[low];
      low--;
    }
//    cout << low << " " << up << " " << sum << "\n";
  }
  if(l <= sum && sum <= u){
    for(int i = low; i <= up; i++){
      ans.push_back(w[i]);
    }
    return ans;
  }
  return vector<int>(0);
}
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1079 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 376 KB Time limit exceeded
2 Halted 0 ms 0 KB -