Submission #448380

#TimeUsernameProblemLanguageResultExecution timeMemory
448380tredsused70Detecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
typedef long long ll; int find_subset(int l,int u,int mas_[],int n,int ans[]) { int used[100100]={0},m=0,pos; array<int,2> mas[100100]; ll sum=0; for(int i=0;i<n;i++) mas[i]={mas_[i],i+1}; sort(mas,mas+n); for(int i=0;i<n;i++) { sum+=mas[i][0]; if(sum>u) { sum-=mas[i][0]; break; } used[mas[i][1]]=1; ans[m]=mas[i][1]; m++; if(sum>=l) return m; } for(int i=m-1;i>=0;i--) { if(used[mas[n-m+i][1]]) continue; used[mas[i][1]]=0; used[mas[n-m+i][1]]=1; sum-=mas[i][0]; sum+=mas[n-m+i][0]; ans[i]=mas[n-m+i][1]; if(sum>=l) return m; } return 0; }

Compilation message (stderr)

molecules.cpp: In function 'int find_subset(int, int, int*, int, int*)':
molecules.cpp:6:5: error: 'array' was not declared in this scope
    6 |     array<int,2> mas[100100];
      |     ^~~~~
molecules.cpp:6:11: error: expected primary-expression before 'int'
    6 |     array<int,2> mas[100100];
      |           ^~~
molecules.cpp:9:9: error: 'mas' was not declared in this scope; did you mean 'mas_'?
    9 |         mas[i]={mas_[i],i+1};
      |         ^~~
      |         mas_
molecules.cpp:10:10: error: 'mas' was not declared in this scope; did you mean 'mas_'?
   10 |     sort(mas,mas+n);
      |          ^~~
      |          mas_
molecules.cpp:10:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   10 |     sort(mas,mas+n);
      |     ^~~~
      |     short
molecules.cpp:5:30: warning: unused variable 'pos' [-Wunused-variable]
    5 |     int used[100100]={0},m=0,pos;
      |                              ^~~