Submission #1008724

#TimeUsernameProblemLanguageResultExecution timeMemory
1008724giorgi_pkhaladzeCollecting Stamps 3 (JOI20_ho_t3)C++14
0 / 100
460 ms1048576 KiB
#pragma.GCCoptimise("Ofast") #include <bits/stdc++.h> #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define pb push_back using namespace std; ll n,m,k,i,j,ans,a[205],t[205],d[205][205][25][205]; ll check(int l, int r, int pos, int cnt){ if(cnt==0)return 1e14; if(l>r)return -1e14; if(d[l][r][pos][cnt]!=-1)return d[l][r][pos][cnt]; ll ans=-1e14; int lc; if(pos==0) lc=l-1; else lc=r+1; ans=max(ans,check(l+1,r,0,cnt)-(min(abs(a[l]-a[lc]),m-abs(a[l]-a[lc])))); ans=max(ans,check(l,r-1,1,cnt)-(min(abs(a[r]-a[lc]),m-abs(a[r]-a[lc])))); ans=max(ans,min(t[l],check(l+1,r,0,cnt-1))-(min(abs(a[l]-a[lc]),m-abs(a[l]-a[lc])))); ans=max(ans,min(t[r],check(l,r-1,1,cnt-1))-(min(abs(a[r]-a[lc]),m-abs(a[r]-a[lc])))); d[l][r][pos][cnt]=ans; return ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin>>n>>m; for(k=0; k<n; k++)cin>>a[k]; for(k=0; k<n; k++)cin>>t[k]; memset(d,-1,sizeof d); ll fans=0; for(k=0; k<=n; k++) { if(check(0,n-1,1,k)>=0)fans=k;} cout<<fans; }

Compilation message (stderr)

ho_t3.cpp:1: warning: ignoring '#pragma . GCCoptimise' [-Wunknown-pragmas]
    1 | #pragma.GCCoptimise("Ofast")
      |
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...