Submission #1091821

#TimeUsernameProblemLanguageResultExecution timeMemory
1091821modwweRobots (APIO13_robots)C++17
0 / 100
2 ms344 KiB
//#include "game.h" //#pragma GCC optimize("conserve-stack") #pragma GCC optimize("Ofast,unroll-loops") #include<bits/stdc++.h> #define int long long #define ll long long #define down cout<<'\n'; #define debug cout<<" cucuucucuuu",down #define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0); #define modwwe int t;cin>>t; while(t--) #define bit(i,j) (i>>j&1) #define sobit(a) __builtin_popcountll(a) #define task "test" #define fin(x) freopen(x".inp","r",stdin) #define fou(x) freopen(x".out","w",stdout) #define pb push_back #define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms"; using namespace std; #define getchar_unlocked getchar inline int scan() { char c = getchar_unlocked(); int x = 0; while(c<'0'||c>'9') { c=getchar_unlocked(); } while(c>='0'&&c<='9') { x=(x<<1)+(x<<3)+c-'0'; c=getchar_unlocked(); } return x; } void phongbeo(); const int inf=1e9; const int mod2=1e9+9; const int mod1=998244353; struct icd { long double a; int b; }; struct ib { int a; int b; }; struct ic { int a,b,c; }; struct id { int a,b,c,d; }; struct ie { int a,b,c,d,e; }; int n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,dem4,l,r,mid,l2,r2,center; int i,s10,s12; int kk; int el=19; main() { //#ifndef ONLINE_JUDGE fin(task); fou(task); //#endif NHP /// cin>>s1; ///modwwe phongbeo(),down // checktime } int a[2001]; vector<int> vv; int dp[2002][2002]; int st[11][2001]; int dp2[2002][2002]; int f[2002]; int get(int l,int r) { int kk=log2(r-l+1); return min(st[kk][l],st[kk][r-(1<<kk)+1]); } void phongbeo() { cin>>n>>m; for(int i=1; i<=n; i++) cin>>a[i],vv.pb(a[i]); sort(vv.begin(),vv.end()); vv.erase(unique(vv.begin(), vv.end()), vv.end()); for(int i=1; i<=n; i++) { st[0][i]=lower_bound(vv.begin(),vv.end(),a[i])-vv.begin()+1; } for(int i=1; i<11; i++) for(int j=1; j+(1<<i)-1<=n; j++) st[i][j]=min(st[i-1][j],st[i-1][j+(1<<(i-1))]); k=vv.size(); for(int i=2;i<=n;i++) for(int j=1;j<=k;j++) dp[i][j]=dp2[i][j]=-inf; for(int j=1;j<=k;j++) dp2[1][j]=-inf; s6=0; for(int i=1; i<=n; i++) { s9=inf; f[1]=dp[i][1]; for(int j=2;j<=k;j++) f[j]=max(dp[i][j],f[j-1]); for(int j=k-1; j>=1; --j) dp[i][j]=max(dp[i][j+1],dp[i][j]); for(int j=2; j<=k; j++) dp2[i][j]=max(dp2[i][j],dp2[i][j-1]); for(int j=i+1; j<=min(n+1,i+m-1); j++) { s2=get(i,j-1) ; s3=vv[s2-1]*(j-i); s4=dp[i][s2]+s3; dp[j][k]=max(dp2[i][s2]+s3,dp[j][k]); dp[j][s2]=max(dp[j][s2],s4); } if(i+m<=n){ s2=get(i,i+m-1) ; s3=vv[s2-1]*m; s4=dp[i][s2]+s3; s4=max(s4,dp2[i][s2]+s3); dp[i+m][k]=max(dp[i+m][s2],s4); dp2[i+m][s2]=s4; s4=inf; } else { s3=n-m+1; s5=get(i,n); cout<<dp[i][s5],down // s6=max(s6,dp2[i][k]+vv[s5-1]*(n+1-i)); s6=max(s6,dp[i][s5]+vv[s5-1]*(n+1-i)); } } cout<<s6; }

Compilation message (stderr)

robots.cpp:70:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   70 | main()
      | ^~~~
robots.cpp: In function 'void phongbeo()':
robots.cpp:108:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  108 |  for(int i=2;i<=n;i++)
      |  ^~~
robots.cpp:111:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  111 |     for(int j=1;j<=k;j++)
      |     ^~~
robots.cpp: In function 'int main()':
robots.cpp:14:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 | #define fin(x) freopen(x".inp","r",stdin)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~
robots.cpp:73:5: note: in expansion of macro 'fin'
   73 |     fin(task);
      |     ^~~
robots.cpp:15:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 | #define fou(x) freopen(x".out","w",stdout)
      |                ~~~~~~~^~~~~~~~~~~~~~~~~~~~
robots.cpp:74:5: note: in expansion of macro 'fou'
   74 |     fou(task);
      |     ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...