Submission #995064
Source Code Expand
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
#define TSUKASA_DIARY_S_TEMPLATE
// define
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) int((a).size())
#define cauto const auto
// typedef
typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;
template< typename T > using Matrix = Vec< Vec< T > >;
template< typename T > using USet = unordered_set< T >;
template< typename T, class C > using MyUSet = unordered_set< T, C >;
template< typename T, typename F > using UMap = unordered_map< T, F >;
template< typename T, typename F, class C > using MyUMap = unordered_map< T, F, C >;
// hash
class PiiHash { public: size_t operator () (const pii& p) const { return (p.first << 16) | p.second; } };
// popcount
inline int POPCNT(int x) { return __builtin_popcount(x); }
inline int POPCNT(lint x) { return __builtin_popcount(x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
const Double EPS = 1e-9;
const Double PI = acos(-1);
// inrange
template< typename T >
inline bool in_range(T v, T mi, T mx) { return mi <= v && v < mx; }
template< typename T >
inline bool in_range(T x, T y, T W, T H) { return in_range(x,0,W) && in_range(y,0,H); }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
template< typename T > inline void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > inline void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > inline void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > inline void maxUpdate(T& a, T b) { a = max(a, b); }
// converter
template< typename F, typename T >
inline void convert(F& from, T& to) {
stringstream ss;
ss << from; ss >> to;
}
lint N, A;
map< pii, int > dp;
void solve() {
dp[pii(0, 1)] = 0;
priority_queue< pii, Vec< pii >, greater< pii > > que; que.push(pii(0, 1));
while (!que.empty()) {
pii p = que.top(); que.pop();
if (dp[p] >= N) {
cout << p.first << endl;
break;
}
int y = dp[p];
pii np1(p.first + A, y);
if (dp.count(np1) == 0) que.push(np1);
pii np0(p.first + 1, p.second);
if (dp[np0] < p.second + y) {
dp[np0] = p.second + y;
que.push(np0);
}
}
}
int main() {
cin >> N >> A;
if (N <= 1000000 && A <= 1000000) {
solve();
}
}
Submission Info
Submission Time |
|
Task |
E - Cookies |
User |
tsukasa_diary |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
2696 Byte |
Status |
WA |
Exec Time |
2107 ms |
Memory |
83172 KB |
Judge Result
Set Name |
sample |
dataset1 |
dataset2 |
Score / Max Score |
0 / 0 |
0 / 500 |
0 / 500 |
Status |
|
|
|
Set Name |
Test Cases |
sample |
sample-01.txt, sample-02.txt, sample-03.txt |
dataset1 |
sample-01.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt |
dataset2 |
sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt, 01-15.txt, 01-16.txt, 01-17.txt, 01-18.txt, 01-19.txt, 01-20.txt, 01-21.txt, 01-22.txt, 01-23.txt, 01-24.txt, 01-25.txt, 01-26.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, 02-14.txt, 02-15.txt, 02-16.txt, 02-17.txt, 02-18.txt, 02-19.txt, 02-20.txt, 02-21.txt, 02-22.txt, 02-23.txt, 02-24.txt, 02-25.txt, 02-26.txt, 02-27.txt, 02-28.txt, 02-29.txt, 02-30.txt, 02-31.txt, 02-32.txt, 02-33.txt, 02-34.txt, 02-35.txt, 02-36.txt, 02-37.txt, 02-38.txt, 02-39.txt, 02-40.txt |
Case Name |
Status |
Exec Time |
Memory |
01-01.txt |
AC |
12 ms |
1408 KB |
01-02.txt |
AC |
26 ms |
2432 KB |
01-03.txt |
AC |
56 ms |
3448 KB |
01-04.txt |
AC |
63 ms |
4472 KB |
01-05.txt |
AC |
76 ms |
5624 KB |
01-06.txt |
AC |
84 ms |
6644 KB |
01-07.txt |
AC |
122 ms |
10996 KB |
01-08.txt |
AC |
195 ms |
17904 KB |
01-09.txt |
AC |
377 ms |
36588 KB |
01-10.txt |
AC |
863 ms |
83048 KB |
01-11.txt |
AC |
868 ms |
83048 KB |
01-12.txt |
TLE |
2107 ms |
83172 KB |
01-13.txt |
AC |
1911 ms |
70504 KB |
01-14.txt |
AC |
14 ms |
1152 KB |
01-15.txt |
AC |
10 ms |
1152 KB |
01-16.txt |
AC |
21 ms |
1920 KB |
01-17.txt |
AC |
116 ms |
10996 KB |
01-18.txt |
AC |
2 ms |
256 KB |
01-19.txt |
AC |
2 ms |
256 KB |
01-20.txt |
AC |
2 ms |
256 KB |
01-21.txt |
AC |
2 ms |
256 KB |
01-22.txt |
AC |
2 ms |
256 KB |
01-23.txt |
AC |
2 ms |
256 KB |
01-24.txt |
AC |
2 ms |
256 KB |
01-25.txt |
AC |
2 ms |
256 KB |
01-26.txt |
AC |
2 ms |
256 KB |
02-01.txt |
WA |
2 ms |
256 KB |
02-02.txt |
WA |
2 ms |
256 KB |
02-03.txt |
WA |
2 ms |
256 KB |
02-04.txt |
WA |
2 ms |
256 KB |
02-05.txt |
WA |
2 ms |
256 KB |
02-06.txt |
WA |
2 ms |
256 KB |
02-07.txt |
WA |
2 ms |
256 KB |
02-08.txt |
WA |
2 ms |
256 KB |
02-09.txt |
WA |
2 ms |
256 KB |
02-10.txt |
WA |
2 ms |
256 KB |
02-11.txt |
WA |
2 ms |
256 KB |
02-12.txt |
WA |
2 ms |
256 KB |
02-13.txt |
WA |
2 ms |
256 KB |
02-14.txt |
WA |
2 ms |
256 KB |
02-15.txt |
WA |
2 ms |
256 KB |
02-16.txt |
WA |
2 ms |
256 KB |
02-17.txt |
WA |
2 ms |
256 KB |
02-18.txt |
WA |
2 ms |
256 KB |
02-19.txt |
WA |
2 ms |
256 KB |
02-20.txt |
WA |
2 ms |
256 KB |
02-21.txt |
WA |
2 ms |
256 KB |
02-22.txt |
WA |
2 ms |
256 KB |
02-23.txt |
WA |
2 ms |
256 KB |
02-24.txt |
WA |
2 ms |
256 KB |
02-25.txt |
WA |
2 ms |
256 KB |
02-26.txt |
WA |
2 ms |
256 KB |
02-27.txt |
WA |
2 ms |
256 KB |
02-28.txt |
WA |
2 ms |
256 KB |
02-29.txt |
WA |
2 ms |
256 KB |
02-30.txt |
WA |
2 ms |
256 KB |
02-31.txt |
WA |
2 ms |
256 KB |
02-32.txt |
WA |
2 ms |
256 KB |
02-33.txt |
WA |
2 ms |
256 KB |
02-34.txt |
WA |
2 ms |
256 KB |
02-35.txt |
WA |
2 ms |
256 KB |
02-36.txt |
WA |
2 ms |
256 KB |
02-37.txt |
WA |
2 ms |
256 KB |
02-38.txt |
WA |
2 ms |
256 KB |
02-39.txt |
WA |
2 ms |
256 KB |
02-40.txt |
WA |
2 ms |
256 KB |
sample-01.txt |
AC |
2 ms |
384 KB |
sample-02.txt |
WA |
2 ms |
256 KB |
sample-03.txt |
AC |
30 ms |
2940 KB |