Submission #328802

#TimeUsernameProblemLanguageResultExecution timeMemory
328802ryangohcaSnail (NOI18_snail)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define int long long using namespace std; vector<int> changes; main() { int h, n; cin >> h >> n; for (int i = 0; i < n*2; i++){ if (i >= n){ changes.push_back(changes[i-n]); } else { int g; cin >> g; changes.push_back(g); } } int s = 0; for (int i = 0; i < n*2; i++){ s += changes[i]; s = max(s, 0); if (s >= h){ cout << i/n << ' ' << i%n << '\n'; return 0; } } s = accumulate(changes.begin(), changes.end(), 0ll); if (s <= 0) { cout << "-1 -1\n"; return 0; } else { int d = h/s * 2; int climbed = d*s; if (climbed >= h){ cout << d << ' ' << n - 1 << "\n"; return 0; } d++; for (int i = 0; i < n*2; i++){ if (i == n) d++; climbed += changes[i]; if (climbed >= h){ cout << d << ' ' << i % n << '\n'; return 0; } } } }

Compilation message (stderr)

snail.cpp:5:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    5 | main() {
      |      ^
snail.cpp: In function 'int main()':
snail.cpp:18:21: error: no matching function for call to 'max(long long int&, int)'
   18 |         s = max(s, 0);
      |                     ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from snail.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
snail.cpp:18:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |         s = max(s, 0);
      |                     ^
In file included from /usr/include/c++/9/bits/specfun.h:45,
                 from /usr/include/c++/9/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:41,
                 from snail.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
snail.cpp:18:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 |         s = max(s, 0);
      |                     ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from snail.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
snail.cpp:18:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |         s = max(s, 0);
      |                     ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from snail.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
snail.cpp:18:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 |         s = max(s, 0);
      |                     ^