답안 #297823

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
297823 2020-09-12T02:43:16 Z khangal Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> find_subset(int l, int u, vector<int> w){
	int n = w.size();
	vector<pair<int,int>> vp;
	vp.resize(n);
    vector<int> ans;
    for(int i=0;i<n;i++){
        vp[i]={w[i],i};
    }
    sort(vp.begin(),vp.end());
    ll sum = 0,j = 0;
    for(int i=0;i<n;i++){
        while(j < n && sum < l){
        	sum += vp[j].first;
        	j++;
		}
        if(sum >= l && sum <= u){
            for(int o=i;o<j;o++){
                ans.push_back(vp[o].second);
            }
            return ans;
        }
        sum -= vp[i].first;
    }
    return vector<int>();
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:13:5: error: 'll' was not declared in this scope; did you mean 'l'?
   13 |     ll sum = 0,j = 0;
      |     ^~
      |     l
molecules.cpp:15:15: error: 'j' was not declared in this scope
   15 |         while(j < n && sum < l){
      |               ^
molecules.cpp:15:24: error: 'sum' was not declared in this scope
   15 |         while(j < n && sum < l){
      |                        ^~~
molecules.cpp:19:12: error: 'sum' was not declared in this scope
   19 |         if(sum >= l && sum <= u){
      |            ^~~
molecules.cpp:20:27: error: 'j' was not declared in this scope
   20 |             for(int o=i;o<j;o++){
      |                           ^
molecules.cpp:25:9: error: 'sum' was not declared in this scope
   25 |         sum -= vp[i].first;
      |         ^~~