Submission #680949

#TimeUsernameProblemLanguageResultExecution timeMemory
680949Tuanlinh123Collecting Stamps 3 (JOI20_ho_t3)C++17
0 / 100
2090 ms328 KiB
#include<bits/stdc++.h> #define ll long long #define ld long double #define pll pair<ll,ll> #define mp make_pair #define pb push_back #define fi first #define se second using namespace std; #define LOCALIO "C:/Users/admin/Documents/Code/" ll n, L; ll a[205], t[205]; ll p[205], used[205], ans; ll dis(ll a, ll b) { ll Max=max(a, b), Min=min(a, b); return min(Max-Min, Min-Max+L); } void show() { ll res=0, crr=0, pos=0; for (ll i=1; i<=n; i++) crr+=dis(pos, a[p[i]]), pos=a[p[i]], res+=crr<=t[p[i]]; ans=max(ans, res); } void backtrack(ll i) { if (i==n+1) { show(); return; } for (ll j=1; j<=n; j++) if (!used[j]) { used[j]=1; p[i]=j; backtrack(i+1); used[j]=0; } } int main() { #ifdef LOCAL freopen( LOCALIO "input.txt","r",stdin) ; freopen( LOCALIO "output.txt","w",stdout) ; #endif ios_base::sync_with_stdio(NULL); cin.tie(nullptr); cout.tie(nullptr); // freopen("FIBONACCI.inp","r",stdin); // freopen("FIBONACCI.out","w",stdout); cin >> n >> L; for (ll i=1; i<=n; i++) cin >> a[i]; for (ll i=1; i<=n; i++) cin >> t[i]; backtrack(1); cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...