답안 #62400

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
62400 2018-07-28T10:52:58 Z zubec Detecting Molecules (IOI16_molecules) C++14
0 / 100
3 ms 492 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    vector <pair<int, int> > vec;
    for (int i = 0; i < w.size(); i++){
        vec.push_back({w[i], i});
    }
    int needL = -1, needR = -1;
    sort(vec.begin(), vec.end());
    vector <pair<ll, int> > vec2;
    vec2.push_back({0, -1});
    ll sum = 0;
    for (int i = 0; i < vec.size(); i++){
        sum += vec[i].first;
        if (vec[i].first >= l && vec[i].first <= u){
            needL = i;
            needR = i;
        }
        auto it = lower_bound(vec2.begin(), vec2.end(), make_pair(-(l-sum), -2));
        if (it != vec2.end()){
            if (-it->first+sum >= l && -it->first+sum <= u){
                needL = it->second+1;
                needR = i;
            }
        }
        cout << sum << endl;
        vec2.push_back({sum, i});
    }
    if (needL == -1)
        return {};
    vector <int> ansvec;
    for (int i = needL; i <= needR; i++)
        ansvec.push_back(vec[i].second);
    sort(ansvec.begin(), ansvec.end());
    return ansvec;

}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < w.size(); i++){
                     ~~^~~~~~~~~~
molecules.cpp:16:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < vec.size(); i++){
                     ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 492 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Secret is incorrect!
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 376 KB Secret is incorrect!
2 Halted 0 ms 0 KB -