Submission #301374

#TimeUsernameProblemLanguageResultExecution timeMemory
301374errorgornDetecting Molecules (IOI16_molecules)C++14
100 / 100
65 ms6260 KiB
#include "molecules.h"
#include <cstdio>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<int,int> ii;
vector<ii> arr;
long long total;
int l,r;
vector<int> find_subset(int low, int high, vector<int> w) {
    vector<int> res;
    for (int x=0;x<w.size();x++){
        arr.push_back(ii(w[x],x));
    }
    sort(arr.begin(),arr.end());
    for (int x=0;x<w.size();x++){
    }
    r=w.size();
    for (int x=0;x<w.size();x++){
        total+=arr[x].first;
        if (total>high){
            total-=arr[x].first;
            r=x;
            break;
        }
    }
    while (total<low && r<w.size()){
        total+=arr[r].first;
        total-=arr[l].first;
        r++;
        l++;
    }
    if (low<=total && total<=high){
        for (int x=l;x<r;x++){
            res.push_back(arr[x].second);
        }
    }
    return res;
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for (int x=0;x<w.size();x++){
      |                  ~^~~~~~~~~
molecules.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for (int x=0;x<w.size();x++){
      |                  ~^~~~~~~~~
molecules.cpp:19:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int x=0;x<w.size();x++){
      |                  ~^~~~~~~~~
molecules.cpp:27:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     while (total<low && r<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...