답안 #198774

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
198774 2020-01-27T15:23:48 Z AaronNaidu Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

long long n, l, u, sum;
int lp, rp;
pair<long long, long long> weights[200005];

int find_subset(int l, int u, int* w, int n, int* result) {
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    for (int i = 0; i < n; i++)
    {
        weights[i].first = w[i];
        weights[i].second = i;
    }
    sort(weights, weights + n);
    lp = rp = sum = 0;
    while(true) {
        if(sum < l) {
            if(rp == n) {
                break;
            }
            sum += weights[rp].first;
            rp++;
        }
        else if(sum > u) {
            sum -= weights[lp].first;
            lp++;
        }
        else {
            //cout << rp - lp << "\n";
            //int toReturn[rp-lp];
            for (int i = lp; i < rp; i++)
            {
                result[i-lp] = weights[i].second;
            }
            //cout << "DONE";
            return rp-lp;
        }
    }
    return 0;

}

Compilation message

/tmp/ccoCWeEN.o: In function `main':
grader.cpp:(.text.startup+0x152): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status