Submission #319590

# Submission time Handle Problem Language Result Execution time Memory
319590 2020-11-05T15:52:56 Z knon0501 Detecting Molecules (IOI16_molecules) C++14
0 / 100
1 ms 620 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> ans;
    vector<pair<int,int>> a;
    for(int i=0 ; i<w.size() ; i++)a.push_back({w[i],i});
    sort(a.begin(),a.end(),[&](pair<int,int> x,pair<int,int> y){
            return x.first>y.first;
         });
    int idx=0;
    for(auto k: w){
        if(k>=l && k<=u){
            ans={idx};
            return ans;
        }
        idx++;
    }
    long long s=0;

    int n=w.size();

    int j=0;

    for(int i=0 ; i<n ; i++){
        while(s<l && j<n){
            s+=a[j].first;
            j++;
        }
        if(s<=u){
            for(int k=i ; k<j ; k++)ans.push_back(a[k].second);
            sort(ans.begin(),ans.end());
            return ans;
        }

        s-=a[i].first;
    }
    return {};
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for(int i=0 ; i<w.size() ; i++)a.push_back({w[i],i});
      |                   ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB OK (n = 12, answer = YES)
2 Correct 1 ms 620 KB OK (n = 12, answer = YES)
3 Incorrect 1 ms 364 KB sum of weights should be in [307..317] but it is 300
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -