Submission #404865

#TimeUsernameProblemLanguageResultExecution timeMemory
404865TrunktyBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include "boxes.h" #include <iostream> using namespace std; long long mini; long long clock[10000005]; long long cclock[10000005]; long long delivery(int n, int k, int l, int p[]) { for(int i=0;i<n;i++){ if(i<k){ clock[i] = min(p[i]*2,l); } else{ clock[i] = clock[i-k]; clock[i] += min(p[i]*2,l); } } for(int i=n-1;i>=0;i--){ if(i>=n-k){ cclock[i] = min((l-p[i])*2,l); } else{ cclock[i] = cclock[i+k]; cclock[i] += min((l-p[i])*2,l); } } mini = cclock[0]; for(int i=0;i<n;i++){ mini = min(mini,clock[i]+cclock[i+1]); } return mini; }

Compilation message (stderr)

boxes.cpp:5:25: error: 'long long int clock [10000005]' redeclared as different kind of entity
    5 | long long clock[10000005];
      |                         ^
In file included from /usr/include/pthread.h:23,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/gthr-default.h:35,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/gthr.h:148,
                 from /usr/include/c++/10/ext/atomicity.h:35,
                 from /usr/include/c++/10/bits/ios_base.h:39,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from boxes.cpp:2:
/usr/include/time.h:72:16: note: previous declaration 'clock_t clock()'
   72 | extern clock_t clock (void) __THROW;
      |                ^~~~~
boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:10:11: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   10 |    clock[i] = min(p[i]*2,l);
      |           ^
boxes.cpp:10:13: error: assignment of read-only location '*(clock + ((sizetype)i))'
   10 |    clock[i] = min(p[i]*2,l);
      |    ~~~~~~~~~^~~~~~~~~~~~~~~
boxes.cpp:13:11: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   13 |    clock[i] = clock[i-k];
      |           ^
boxes.cpp:13:24: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   13 |    clock[i] = clock[i-k];
      |                        ^
boxes.cpp:13:13: error: assignment of read-only location '*(clock + ((sizetype)i))'
   13 |    clock[i] = clock[i-k];
      |    ~~~~~~~~~^~~~~~~~~~~~
boxes.cpp:14:11: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   14 |    clock[i] += min(p[i]*2,l);
      |           ^
boxes.cpp:14:13: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   14 |    clock[i] += min(p[i]*2,l);
      |    ~~~~~~~~~^~~~~~~~~~~~~~~~
boxes.cpp:14:13: error: assignment of read-only location '*(clock + ((sizetype)i))'
boxes.cpp:28:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   28 |   mini = min(mini,clock[i]+cclock[i+1]);
      |                          ^
boxes.cpp:28:27: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   28 |   mini = min(mini,clock[i]+cclock[i+1]);
      |                   ~~~~~~~~^~~~~~~~~~~~
boxes.cpp:28:39: error: no matching function for call to 'min(long long int&, clock_t (*)() throw ())'
   28 |   mini = min(mini,clock[i]+cclock[i+1]);
      |                                       ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from boxes.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
boxes.cpp:28:39: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'clock_t (*)() throw ()' {aka 'long int (*)()'})
   28 |   mini = min(mini,clock[i]+cclock[i+1]);
      |                                       ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from boxes.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
boxes.cpp:28:39: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'clock_t (*)() throw ()' {aka 'long int (*)()'})
   28 |   mini = min(mini,clock[i]+cclock[i+1]);
      |                                       ^