# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1171701 | SmuggingSpun | Collecting Stamps 3 (JOI20_ho_t3) | C++20 | 381 ms | 664 KiB |
#include<bits/stdc++.h>
#define taskname "C"
using namespace std;
template<class T>void maximize(T& a, T b){
if(a < b){
a = b;
}
}
const int lim = 205;
int n, L, x[lim], t[lim];
namespace sub1{
void solve(){
vector<vector<bool>>dp(L + 1, vector<bool>(1 << n, false));
dp[1][0] = true;
auto fix = [&] (int time){
for(int i = 1; i <= L; i++){
for(int mask = (1 << n) - 1; mask > -1; mask--){
if(dp[i][mask]){
for(int j = 1; j <= n; j++){
if(x[j] == i && t[j] >= time){
dp[i][mask | (1 << (j - 1))] = true;
break;
}
}
}
}
}
};
fix(1);
for(int time = 2; time < lim; time++){
vector<vector<bool>>ndp(L + 1, vector<bool>(1 << n, false));
for(int i = 1; i <= L; i++){
for(int mask = (1 << n) - 1; mask > -1; mask--){
if(dp[i][mask]){
ndp[i == 1 ? L - 1 : i - 1][mask] = ndp[i == L - 1 ? 1 : i + 1][mask] = true;
}
}
}
swap(dp, ndp);
fix(time);
}
int ans = 0;
for(int i = 1; i <= L; i++){
for(int mask = (1 << n) - 1; mask > 0; mask--){
if(dp[i][mask]){
maximize(ans, __builtin_popcount(mask));
}
}
}
cout << ans;
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> n >> L;
for(int i = 1; i <= n; i++){
cin >> x[i];
}
for(int i = 1; i <= n; i++){
cin >> t[i];
}
if(n <= 12 && L <= 200 && *max_element(t + 1, t + n + 1) <= 200){
sub1::solve();
}
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |