답안 #1114582

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1114582 2024-11-19T08:13:50 Z lftroq Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#include "molecules.h"

using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
    vector<pair<int,int>> a;
    for(int i=0;i<(int)size();i++) a.push_back({w[i],i});
    sort(a.begin(),a.end());
    long long s=0;
    for(int i=0,j=0;i<(int)w.size();i++)
    {
        s+=a[i].first;
        while(s>u) s-=a[j++].first;
        if(s>=l)
        {
            vector<int> ans;
            for(int k=j;k<=i;k++) ans.push_back(a[k].second);
            return ans;
        }
    }
    return {};
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:24: error: 'size' was not declared in this scope; did you mean 'dysize'?
    8 |     for(int i=0;i<(int)size();i++) a.push_back({w[i],i});
      |                        ^~~~
      |                        dysize