Submission #849749

#TimeUsernameProblemLanguageResultExecution timeMemory
849749chilengamingDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms600 KiB
#include<bits/stdc++.h>
#include "molecules.h"

using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
    vector<int> ans;
    vector<pair<int, int>> ww;
    int i = 0;
    for(int &a : w) {
        ww.push_back({a, i});
        i++;
    }
    sort(ww.begin(), ww.end());
    long long pre[ww.size() + 1];
    pre[0] = 0;
    for(int i = 0; i < ww.size(); i++) {
        pre[i + 1] = pre[i] + ww[i].first;
    }
    for(int L = 0; L < ww.size(); L++) {
        int R = lower_bound(pre + 1, pre + 1 + ww.size(), pre[L] + l) - pre;
        if(R > ww.size()) continue;
        long long sum = pre[R] - pre[L];
        if(sum >= l && sum <= u) {
            for(int j = L; j < R; j++) {
                ans.push_back(j);
            }
            return ans;
        }
    }
    return ans;
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:17:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i = 0; i < ww.size(); i++) {
      |                    ~~^~~~~~~~~~~
molecules.cpp:20:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |     for(int L = 0; L < ww.size(); L++) {
      |                    ~~^~~~~~~~~~~
molecules.cpp:22:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         if(R > ww.size()) continue;
      |            ~~^~~~~~~~~~~
#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...