제출 #1171701

#제출 시각아이디문제언어결과실행 시간메모리
1171701SmuggingSpunCollecting Stamps 3 (JOI20_ho_t3)C++20
5 / 100
381 ms664 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) 메시지

ho_t3.cpp: In function 'int main()':
ho_t3.cpp:56:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   56 |                 freopen(taskname".inp", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...