답안 #535320

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
535320 2022-03-10T02:39:48 Z Biaz Collecting Stamps 3 (JOI20_ho_t3) C++17
0 / 100
0 ms 212 KB
#include<bits/stdc++.h>
//#define int long long
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define fi first
#define se second
#define ist insert
using namespace std;
int min(int a,int b){return a<b?a:b;}
int max(int a,int b){return a>b?a:b;}
typedef long long ll;
typedef pair<ll,ll> pii;
const int N=205;
const int MOD=1000000007;//998244353
const int INF=2147483647;//1700000000000000000

int n,L;
int a[N];
int t[N];
int tmp[N];
inline void sol(){
    cin >>n>>L;
    fill(t,t+N,-1);
    for (int i=0;i<n;i++) cin >>a[i];
    for (int i=0,k;i<n;i++) cin >>k,t[a[i]]=k;
    
    int ans=0;
    for (int rev=0;rev<=L;rev++){
        for (int i=0;i<=L;i++) tmp[i]=t[i];
        int tot=0;
        for (int i=0;i<=rev;i++){
            if (tmp[L-i]!=-1&&tmp[L-i]>=i)
                tot++,tmp[L-i]=-1;
        }
        for (int i=1;i<=L-rev;i++){
            if (tmp[i]!=-1&&tmp[i]>=rev*2+i)
                tot++,tmp[i]=-1;
        }
        ans=max(ans,tot);
        //cout <<rev<<' '<<tot<<'\n';
    }

    for (int wlk=0;wlk<=L;wlk++){
        for (int i=0;i<=L;i++) tmp[i]=t[i];
        int tot=0;
        for (int i=0;i<=wlk;i++){
            if (tmp[i]!=-1&&tmp[i]>=i){
                tot++,tmp[i]=-1;
                //if (wlk==2) cout <<i<<' '<<tot<<'\n';
            }
        }
        for (int i=1;i<=L-wlk;i++){
            if (tmp[L-i]!=-1&&tmp[L-i]>=wlk*2+i){
                tot++,tmp[L-i]=-1;
                //if (wlk==2) cout <<wlk*2+i<<' '<<tot<<'\n';
            }
        }
        ans=max(ans,tot);
        //cout <<wlk<<' '<<tot<<'\n';
    }
    cout <<ans<<'\n';
}
signed main(){
    int _=1;
    //cin >>_;
    while (_--) sol();
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -