Submission #164744

# Submission time Handle Problem Language Result Execution time Memory
164744 2019-11-23T06:42:13 Z quocnguyen1012 Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;

const int maxn = 2e5 + 5;

pair<int, int> a[maxn];
int N, L, R;
ll sum[maxn];

signed main(void)
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (fopen("A.INP", "r")){
        freopen("A.INP", "r", stdin);
        freopen("A.OUT", "w", stdout);
    }

    cin >> N >> L >> R;
    for (int i=1; i<=N; ++i){
        cin >> a[i].fi;
        a[i].se = i;
    }
    sort(a+1, a+1+N);
    ll sum = 0;
    for (int i=1, j=1; i<=N; ++i){
        sum += a[i].fi;
        while (sum > R){
            sum -= a[j].fi;
            ++j;
        }
        if (sum >= L){
            for (int k=j; k<=i; ++k){
                cout << a[k].se - 1 << ' ';
            }
            return 0;
        }
    }
}

Compilation message

molecules.cpp: In function 'int main()':
molecules.cpp:21:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen("A.INP", "r", stdin);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
molecules.cpp:22:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
         freopen("A.OUT", "w", stdout);
         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/tmp/cckih8Ci.o: In function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccEuniEJ.o:molecules.cpp:(.text.startup+0x0): first defined here
/tmp/cckih8Ci.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