제출 #956958

#제출 시각아이디문제언어결과실행 시간메모리
956958modwweCigle (COI21_cigle)C++17
100 / 100
203 ms181216 KiB
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define down cout<<'\n';
#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;
void phongbeo();
const int mod2=1e9+7;
const int  mod1=998244353;
struct ib
{
    int a;
    int b;
};
struct icd
{
    int a,b;
};
struct ic
{
    int a,b,c;
};
struct id
{
    int a,b,c,d;
};
int n,m,s2,s4,s3,sf,k,r,mid,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,l;
int  i,s10,s12;
int el=29;
main()
{
//#ifndef ONLINE_JUDGE
    // fin(task),fou(task);
//#endif
    NHP
//modwwe
    //  cin>>res;
    phongbeo(),down
    checktime
}
int a[5002];
int dp[5002][5002];
int dp2[5002];
void phongbeo()
{
 cin>>n;/// hieu sai de cay vl
 for(int i=1;i<=n;i++)
     cin>>a[i];
     for(int i=1;i<=n;i++)
        a[i]+=a[i-1];
        //cout<<a[i],down
     for(int i=1;i<=n-1;i++)
     {dp2[0]=-1e18;
         for(int j=1;j<i;j++)
            dp2[j]=dp[j][i];
         for(int j=1;j<i;j++)
            dp2[j]=max(dp2[j],dp2[j-1]);
          l=i-1;
           k=i;
           s3=0;
           s4=0;
           s5=0;
          // if(i==8)
           //cout<<dp2[3],down
          for(int j=i+1;j<=n;j++)
          { s4=a[j];
          dp[i+1][j]=s5;
               if(j==n+1) break;
                  ///  dp[i][j]=max(dp[j],dp[j-1]);
                //  if(i==8) cout<<s3<<" "<<s2+s4<<" "<<s2<<" "<<s4<<" "<<a[i]<<" "<<k<<" "<<j,down
               while(k>0&&a[k]+a[j]>a[i]*2)
               {
                   k--;
               }

                if(a[k]+a[j]==a[i]*2&&k>0){
                s3++;
                s5=max(s5,s3+dp2[k]);
                    }
          }
          s7=max(s7,dp[i+1][n]);
      ///    cout<<dp[n]<<" "<<s3<<" "<<dp[4],down
     }
cout<<s7;//<<" "<<dp[3][8];
}

컴파일 시 표준 에러 (stderr) 메시지

cigle.cpp:40:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   40 | main()
      | ^~~~
cigle.cpp: In function 'void phongbeo()':
cigle.cpp:57:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   57 |  for(int i=1;i<=n;i++)
      |  ^~~
cigle.cpp:59:6: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   59 |      for(int i=1;i<=n;i++)
      |      ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...