Submission #448379

#TimeUsernameProblemLanguageResultExecution timeMemory
448379tredsused70Detecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
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:4:5: error: 'array' was not declared in this scope
    4 |     array<int,2> mas[100100];
      |     ^~~~~
molecules.cpp:4:11: error: expected primary-expression before 'int'
    4 |     array<int,2> mas[100100];
      |           ^~~
molecules.cpp:5:5: error: 'll' was not declared in this scope; did you mean 'l'?
    5 |     ll sum=0;
      |     ^~
      |     l
molecules.cpp:7:9: error: 'mas' was not declared in this scope; did you mean 'mas_'?
    7 |         mas[i]={mas_[i],i+1};
      |         ^~~
      |         mas_
molecules.cpp:8:10: error: 'mas' was not declared in this scope; did you mean 'mas_'?
    8 |     sort(mas,mas+n);
      |          ^~~
      |          mas_
molecules.cpp:8:5: error: 'sort' was not declared in this scope; did you mean 'short'?
    8 |     sort(mas,mas+n);
      |     ^~~~
      |     short
molecules.cpp:11:9: error: 'sum' was not declared in this scope
   11 |         sum+=mas[i][0];
      |         ^~~
molecules.cpp:29:9: error: 'sum' was not declared in this scope
   29 |         sum-=mas[i][0];
      |         ^~~
molecules.cpp:3:30: warning: unused variable 'pos' [-Wunused-variable]
    3 |     int used[100100]={0},m=0,pos;
      |                              ^~~