Submission #1367835

#TimeUsernameProblemLanguageResultExecution timeMemory
1367835FaresSTH나일강 (IOI24_nile)C++20
Compilation error
0 ms0 KiB
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
#define S second
#define F first
struct artifact{int w,a,b,c};
vector<long long>calculate_costs(vector<int>w,vector<int>a,vector<int>b,vector<int>e){
	int n=w.size();
	vector<artifact>v(n);
	for(int i=0;i<n;i++)v[i]=artifact{w[i],a[i],b[i],a[i]-b[i]};
	sort(v.begin(),v.end(),[](auto a,auto b){return a.c<b.c;});
	return accumulate(b.begin(),b.end())+(n%2?v.back().c:0);
}

Compilation message (stderr)

nile.cpp:6:27: error: expected ';' at end of member declaration
    6 | struct artifact{int w,a,b,c};
      |                           ^
      |                            ;
nile.cpp: In function 'std::vector<long long int> calculate_costs(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
nile.cpp:12:26: error: no matching function for call to 'accumulate(std::vector<int>::iterator, std::vector<int>::iterator)'
   12 |         return accumulate(b.begin(),b.end())+(n%2?v.back().c:0);
      |                ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/numeric:62,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:58,
                 from nile.cpp:1:
/usr/include/c++/13/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> constexpr _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
  134 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~~~~~
/usr/include/c++/13/bits/stl_numeric.h:134:5: note:   template argument deduction/substitution failed:
nile.cpp:12:26: note:   candidate expects 3 arguments, 2 provided
   12 |         return accumulate(b.begin(),b.end())+(n%2?v.back().c:0);
      |                ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> constexpr _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  161 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~~~~~
/usr/include/c++/13/bits/stl_numeric.h:161:5: note:   template argument deduction/substitution failed:
nile.cpp:12:26: note:   candidate expects 4 arguments, 2 provided
   12 |         return accumulate(b.begin(),b.end())+(n%2?v.back().c:0);
      |                ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~