This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
long long N, K, L; | |
long long A[1 << 18]; | |
bool solve(long long M) { | |
long long cnt = 0, pre = 0; | |
for (int i = 1; i <= N; i++) { | |
if (A[i] - pre >= M && L - A[i] >= M) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
int N, L; | |
int V[109], W[109], C[109]; | |
int dp[109][1009]; | |
vector<pair<int, int>> vec[109]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
《DP の配列》 | |
・dp[タイプいくつまで考えたか][値段合計] = (kcal 最大) | |
・答えは dp[K][L] | |
《状態遷移》 | |
まず、タイプ i の商品の買い方は以下の c[i]+1 通りしかありません。ただし c[i] = (タイプ i の商品の個数) とします。 | |
・タイプ i の商品をどれか 1 個選び、それを買う。(c[i] 通り) | |
・タイプ i の商品を買わない。(1 通り) | |
・それぞれ (カロリー増加分, 値段増加分) = (a[1], b[1]), ..., (a[c[i] + 1], b[c[i] + 1]) とする |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
int N, L; | |
int V[1009], W[1009]; | |
int dp[1009][10009][2]; | |
int main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 500 | |
188 151 | |
238 124 | |
173 151 | |
179 118 | |
164 124 | |
179 127 | |
112 127 | |
97 205 | |
59 199 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
int cnts = 0; | |
int dx[4] = { 0, 1, 0, -1 }; | |
int dy[4] = { 1, 0, -1, 0 }; | |
int t[4][4]; | |
int dst[4][4][16]; | |
bool flag = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
struct State { | |
int c[4][4]; | |
}; | |
bool operator<(const State& a1, const State& a2) { |