Submission #213869


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <stdint.h>
using namespace std;

int main()
{
  int64_t n, h; cin>>n>>h;
  int64_t a, b, c, d, e; cin>>a>>b>>c>>d>>e;

  int64_t ans = 0x7fffffffffffffffLL;

  for (int i=0;i<n;i++){
    int64_t h2 = h+i*b;

    // h2+d*j>e*(n-i-j)
    // h2+dj>en-ei-ej
    // (d+e)j>en-ei-h2
    // j > (en-ei-h2)/(d+e)

    int64_t j = (e*n-e*i-h2)/(d+e) + 1;
    j = max(j, 0LL);

    int64_t cost = a*i+c*j;

    // cout << i << ", "<< j << ": " << cost << endl;

    ans = min(ans, cost);
  }

  cout << ans << endl;

  return 0;
}

Submission Info

Submission Time
Task C - 節制
User tanakh
Language C++11 (GCC 4.8.1)
Score 0
Code Size 697 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:27:19: error: no matching function for call to ‘max(int64_t&, long long int)’
     j = max(j, 0LL);
                   ^
./Main.cpp:27:19: note: candidates are:
In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0,
                 from /usr/include/c++/4.8/ios:40,
                 from /usr/include/c++/4.8/ostream:38,
                 from /usr/include/c++/4.8/iostream:39,
                 from ./Main.cpp:1:
/usr/include/c++/4.8/bits/stl_algobase.h:216:5: note: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^
/usr/include/c++/4.8/bits/stl_algobase.h:216:5: note:   template argument deduction/substitution failed:
./Main.cpp:27:19: note:   deduced conflicting types for parameter ‘const _Tp’ (‘long int’ and ‘long long int’)
     j = max(j, 0LL);
                   ^
In file included from /usr/include/c++/4.8/bits/char_traits.h:39:0,
                 from /usr/includ...