제출 #122285

#제출 시각아이디문제언어결과실행 시간메모리
122285turbatDetecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 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> > v;
    for (int i = 0;i < w.size();i++)
    	v.push_back({w[i], i});
    sort(v.begin(), v.end());
    int s = 0, l = 0;;
    for (int i = 0;i < v.size();i++){
    	if (s + v[i].first <= u)
 			s += v[i].first;
    	else {
    		if (s >= l) {
    			for (int j = l;j <= i;j++)
    				ans.push_back(v[j].second);
    			break;
    		}
    		s += v[i].first;
    		s -= v[l].first;
    	}
    }
    // cout << l << ' ' << u << endl;
    // for (int x : ans)
    // 	cout << x<< ' ';
    // cout << endl;
    sort(ans.begin(), ans.end());
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0;i < w.size();i++)
                    ~~^~~~~~~~~~
molecules.cpp:12:16: error: declaration of 'int l' shadows a parameter
     int s = 0, l = 0;;
                ^
molecules.cpp:13:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0;i < v.size();i++){
                    ~~^~~~~~~~~~