제출 #448381

#제출 시각아이디문제언어결과실행 시간메모리
448381tredsused70Detecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> 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; }

컴파일 시 표준 에러 (stderr) 메시지

molecules.cpp: In function 'int find_subset(int, int, int*, int, int*)':
molecules.cpp:8:5: error: 'array' was not declared in this scope; did you mean 'std::array'?
    8 |     array<int,2> mas[100100];
      |     ^~~~~
      |     std::array
In file included from /usr/include/c++/10/tuple:39,
                 from /usr/include/c++/10/functional:54,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from molecules.cpp:1:
/usr/include/c++/10/array:94:12: note: 'std::array' declared here
   94 |     struct array
      |            ^~~~~
molecules.cpp:8:11: error: expected primary-expression before 'int'
    8 |     array<int,2> mas[100100];
      |           ^~~
molecules.cpp:11:9: error: 'mas' was not declared in this scope; did you mean 'mas_'?
   11 |         mas[i]={mas_[i],i+1};
      |         ^~~
      |         mas_
molecules.cpp:12:10: error: 'mas' was not declared in this scope; did you mean 'mas_'?
   12 |     sort(mas,mas+n);
      |          ^~~
      |          mas_
molecules.cpp:12:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   12 |     sort(mas,mas+n);
      |     ^~~~
      |     std::sort
In file included from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from molecules.cpp:1:
/usr/include/c++/10/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
molecules.cpp:7:30: warning: unused variable 'pos' [-Wunused-variable]
    7 |     int used[100100]={0},m=0,pos;
      |                              ^~~