답안 #956958

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
956958 2024-04-02T18:02:40 Z modwwe Cigle (COI21_cigle) C++17
100 / 100
203 ms 181216 KB
#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];
}

Compilation message

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++)
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2516 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2516 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4696 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4448 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 20828 KB Output is correct
2 Correct 3 ms 20828 KB Output is correct
3 Correct 3 ms 20828 KB Output is correct
4 Correct 3 ms 20840 KB Output is correct
5 Correct 3 ms 20840 KB Output is correct
6 Correct 4 ms 20840 KB Output is correct
7 Correct 7 ms 21220 KB Output is correct
8 Correct 3 ms 20840 KB Output is correct
9 Correct 4 ms 20840 KB Output is correct
10 Correct 3 ms 20840 KB Output is correct
11 Correct 3 ms 20840 KB Output is correct
12 Correct 4 ms 20840 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2516 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4696 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4448 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 7 ms 20828 KB Output is correct
22 Correct 3 ms 20828 KB Output is correct
23 Correct 3 ms 20828 KB Output is correct
24 Correct 3 ms 20840 KB Output is correct
25 Correct 3 ms 20840 KB Output is correct
26 Correct 4 ms 20840 KB Output is correct
27 Correct 7 ms 21220 KB Output is correct
28 Correct 3 ms 20840 KB Output is correct
29 Correct 4 ms 20840 KB Output is correct
30 Correct 3 ms 20840 KB Output is correct
31 Correct 3 ms 20840 KB Output is correct
32 Correct 4 ms 20840 KB Output is correct
33 Correct 3 ms 20840 KB Output is correct
34 Correct 3 ms 20840 KB Output is correct
35 Correct 3 ms 20840 KB Output is correct
36 Correct 3 ms 20840 KB Output is correct
37 Correct 4 ms 20840 KB Output is correct
38 Correct 4 ms 20828 KB Output is correct
39 Correct 4 ms 20828 KB Output is correct
40 Correct 4 ms 20824 KB Output is correct
41 Correct 3 ms 20828 KB Output is correct
42 Correct 4 ms 20948 KB Output is correct
43 Correct 4 ms 20828 KB Output is correct
44 Correct 5 ms 20824 KB Output is correct
45 Correct 3 ms 20824 KB Output is correct
46 Correct 4 ms 20828 KB Output is correct
47 Correct 3 ms 20828 KB Output is correct
48 Correct 3 ms 20828 KB Output is correct
49 Correct 4 ms 20828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2516 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 1 ms 4696 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4444 KB Output is correct
14 Correct 1 ms 4448 KB Output is correct
15 Correct 1 ms 4444 KB Output is correct
16 Correct 1 ms 4444 KB Output is correct
17 Correct 1 ms 4444 KB Output is correct
18 Correct 1 ms 4444 KB Output is correct
19 Correct 1 ms 4444 KB Output is correct
20 Correct 1 ms 4444 KB Output is correct
21 Correct 7 ms 20828 KB Output is correct
22 Correct 3 ms 20828 KB Output is correct
23 Correct 3 ms 20828 KB Output is correct
24 Correct 3 ms 20840 KB Output is correct
25 Correct 3 ms 20840 KB Output is correct
26 Correct 4 ms 20840 KB Output is correct
27 Correct 7 ms 21220 KB Output is correct
28 Correct 3 ms 20840 KB Output is correct
29 Correct 4 ms 20840 KB Output is correct
30 Correct 3 ms 20840 KB Output is correct
31 Correct 3 ms 20840 KB Output is correct
32 Correct 4 ms 20840 KB Output is correct
33 Correct 3 ms 20840 KB Output is correct
34 Correct 3 ms 20840 KB Output is correct
35 Correct 3 ms 20840 KB Output is correct
36 Correct 3 ms 20840 KB Output is correct
37 Correct 4 ms 20840 KB Output is correct
38 Correct 4 ms 20828 KB Output is correct
39 Correct 4 ms 20828 KB Output is correct
40 Correct 4 ms 20824 KB Output is correct
41 Correct 3 ms 20828 KB Output is correct
42 Correct 4 ms 20948 KB Output is correct
43 Correct 4 ms 20828 KB Output is correct
44 Correct 5 ms 20824 KB Output is correct
45 Correct 3 ms 20824 KB Output is correct
46 Correct 4 ms 20828 KB Output is correct
47 Correct 3 ms 20828 KB Output is correct
48 Correct 3 ms 20828 KB Output is correct
49 Correct 4 ms 20828 KB Output is correct
50 Correct 199 ms 160392 KB Output is correct
51 Correct 129 ms 161876 KB Output is correct
52 Correct 128 ms 160412 KB Output is correct
53 Correct 134 ms 161992 KB Output is correct
54 Correct 136 ms 173384 KB Output is correct
55 Correct 136 ms 173392 KB Output is correct
56 Correct 166 ms 157728 KB Output is correct
57 Correct 195 ms 181216 KB Output is correct
58 Correct 190 ms 163376 KB Output is correct
59 Correct 191 ms 180688 KB Output is correct
60 Correct 184 ms 166000 KB Output is correct
61 Correct 153 ms 170464 KB Output is correct
62 Correct 145 ms 167424 KB Output is correct
63 Correct 164 ms 155896 KB Output is correct
64 Correct 165 ms 173944 KB Output is correct
65 Correct 137 ms 163100 KB Output is correct
66 Correct 197 ms 166396 KB Output is correct
67 Correct 144 ms 156468 KB Output is correct
68 Correct 172 ms 171960 KB Output is correct
69 Correct 157 ms 171348 KB Output is correct
70 Correct 171 ms 170460 KB Output is correct
71 Correct 203 ms 173392 KB Output is correct
72 Correct 161 ms 167536 KB Output is correct