Submission #93471

# Submission time Handle Problem Language Result Execution time Memory
93471 2019-01-08T16:47:31 Z tpoppo Detecting Molecules (IOI16_molecules) C++14
10 / 100
2 ms 380 KB
#include "molecules.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using pii = pair<ll,int>;

vector<int> res;
vector<pii> v;

vector<int> find_subset(int lw, int u, vector<int> w) {

  v.reserve(w.size());

  for(int i=0;i<w.size();i++){
    v.emplace_back(w[i],i);
  }
  sort(v.begin(),v.end());

  int l = 0;
  ll sum = 0;
  for(int r = 0;r < v.size();r++){
    sum += v[r].first;
    while(sum > u && l < r){
      sum -= v[l].first;
      l++;
    }
    //cout<<l<<" - "<<r<<": "<<sum<<'\n';
    if(sum >= lw){
      for(int i = l;i<=r;i++) res.emplace_back(v[i].second);
      return res;
    }
  }
  return vector<int>();
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:15:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i=0;i<w.size();i++){
               ~^~~~~~~~~
molecules.cpp:22:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int r = 0;r < v.size();r++){
                 ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Incorrect 2 ms 376 KB sum of weights should be in [10..12] but it is 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 12, answer = YES)
2 Correct 2 ms 376 KB OK (n = 12, answer = YES)
3 Correct 2 ms 256 KB OK (n = 12, answer = NO)
4 Correct 2 ms 380 KB OK (n = 12, answer = NO)
5 Correct 2 ms 256 KB OK (n = 12, answer = YES)
6 Correct 2 ms 376 KB OK (n = 12, answer = YES)
7 Correct 2 ms 256 KB OK (n = 12, answer = YES)
8 Correct 2 ms 256 KB OK (n = 12, answer = YES)
9 Correct 2 ms 256 KB OK (n = 6, answer = YES)
10 Correct 2 ms 376 KB OK (n = 12, answer = YES)
11 Correct 2 ms 252 KB OK (n = 100, answer = NO)
12 Correct 2 ms 256 KB OK (n = 100, answer = YES)
13 Correct 2 ms 376 KB OK (n = 100, answer = NO)
14 Correct 2 ms 268 KB OK (n = 100, answer = YES)
15 Correct 2 ms 256 KB OK (n = 100, answer = YES)
16 Correct 2 ms 256 KB OK (n = 100, answer = YES)
17 Correct 2 ms 256 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Incorrect 2 ms 376 KB sum of weights should be in [10..12] but it is 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Incorrect 2 ms 376 KB sum of weights should be in [10..12] but it is 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Incorrect 2 ms 376 KB sum of weights should be in [10..12] but it is 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Incorrect 2 ms 376 KB sum of weights should be in [10..12] but it is 13
3 Halted 0 ms 0 KB -