Submission #284606

# Submission time Handle Problem Language Result Execution time Memory
284606 2020-08-27T17:28:46 Z triplem5ds Detecting Molecules (IOI16_molecules) C++14
0 / 100
1 ms 256 KB
#include "molecules.h"
#include "bits/stdc++.h"
using namespace std;
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    vector<int> v;
    for(int i = 0; i < w.size(); i++)v.push_back(i);
    sort(v.begin(),v.end(), [&](int x, int y){return w[x] < w[y];});
    if(accumulate(w.begin(),w.end(),0ll) < l || w[v[0]] > u)return vector<int>();
    int sum = 0;
    for(int i = 0, j = 0; i < v.size(); i++){
      while(j < v.size() && sum < l)sum += w[v[j]];
      if(sum >= l && sum <= u){
        vector<int> ret;
        for(int k = i; k < j; k++)
          ret.push_back(v[k]);
        return ret;
      }
      sum -= w[v[i]];
    }
    return vector<int>();
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:6:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |     for(int i = 0; i < w.size(); i++)v.push_back(i);
      |                    ~~^~~~~~~~~~
molecules.cpp:10:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i = 0, j = 0; i < v.size(); i++){
      |                           ~~^~~~~~~~~~
molecules.cpp:11:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |       while(j < v.size() && sum < l)sum += w[v[j]];
      |             ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 1 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 1 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 1 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 1 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB OK (n = 1, answer = NO)
2 Correct 1 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -