답안 #305532

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
305532 2020-09-23T13:29:00 Z juggernaut Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;
vector<int>find_subset(int a,int b,vector<int>w){
    vector<int>ans;
    vector<pair<int,int>>v;
    int i,sum=0,l,r=0;
    for(;r<w.size();r++)v.push_back({w[r],r});
    sort(v.begin(),v.end());
    for(r=0;r<w.size();r++){
        sum+=v[i].first;
        while(sum>r)sum-=v[j++].first;
        if(sum>=l){
            for(;l<=r;l++)ans.push_back(v[l].second);
            return ans;
        }
    }
    return {};
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:7:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |     for(;r<w.size();r++)v.push_back({w[r],r});
      |          ~^~~~~~~~~
molecules.cpp:9:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(r=0;r<w.size();r++){
      |             ~^~~~~~~~~
molecules.cpp:11:28: error: 'j' was not declared in this scope
   11 |         while(sum>r)sum-=v[j++].first;
      |                            ^