답안 #282570

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
282570 2020-08-24T14:59:35 Z BeanZ Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
#include "molecules.h"

using namespace std;
#define ll int
#define endl '\n'
const int N = 10005;
const int mod = 1e9 + 7;
vector<ll> find_subset(ll l, ll u, vector<ll> w){
        vector<ll> res;
        vector<pair<ll, ll>> a;
        for (int i = 0; i < w.size(); i++){
                a.push_back({w[i], i});
        }
        sort(a.begin(), a.end());
        ll lf = 0, sum = 0;
        for (int i = 0; i < a.size(); i++){
                sum = sum + a[i].first;
                while (sum > u){
                        sum -= a[lf].first;
                        lf++;
                }
                if (sum >= l){
                        for (int j = lf; j <= i; j++){
                                res.push_back(a[j].second);
                        }
                        break
                }
        }
        return res;
}
/*
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        if (fopen("VietCT.INP", "r")){
                freopen("VietCT.INP", "r", stdin);
                freopen("VietCT.OUT", "w", stdout);
        }
}
*/

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |         for (int i = 0; i < w.size(); i++){
      |                         ~~^~~~~~~~~~
molecules.cpp:17:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |         for (int i = 0; i < a.size(); i++){
      |                         ~~^~~~~~~~~~
molecules.cpp:27:30: error: expected ';' before '}' token
   27 |                         break
      |                              ^
      |                              ;
   28 |                 }
      |                 ~