Submission #444652

#TimeUsernameProblemLanguageResultExecution timeMemory
444652HanksburgerDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
using namespace std;
pair<long long, long long> a[200000];
int[] find_subset(int l, int u, int[] w)
{
	long long n=sizeof(w)/sizeof(w[0]), r=u, index=0, sum=0;
    for (long long i=0; i<n; i++)
    {
        a[i].first=w[i];
        a[i].second=i;
    }
    sort(a, a+n);
    for (long long i=0; i<n; i++)
    {
        while (1)
        {
            if (l<=sum && sum<=r)
            {
            	int ans[index-i];
                for (long long j=i; j<index; j++)
                    ans[j-i]=a[j].second;
                return ans;
            }
            if (index<n && sum<=r)
            {
                sum+=a[index].first;
                index++;
            }
            else
                break;
        }
        sum-=a[i].first;
    }
    int ans[0];
    return ans;
}

Compilation message (stderr)

molecules.cpp:4:4: error: structured binding declaration cannot have type 'int'
    4 | int[] find_subset(int l, int u, int[] w)
      |    ^~
molecules.cpp:4:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
molecules.cpp:4:4: error: empty structured binding declaration
molecules.cpp:4:7: error: expected initializer before 'find_subset'
    4 | int[] find_subset(int l, int u, int[] w)
      |       ^~~~~~~~~~~