답안 #956960

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
956960 2024-04-02T18:03:17 Z modwwe Cigle (COI21_cigle) C++17
100 / 100
223 ms 186628 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) 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 2396 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 2392 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 2396 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 2392 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 4444 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 4444 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 4 ms 20828 KB Output is correct
2 Correct 3 ms 20824 KB Output is correct
3 Correct 3 ms 20824 KB Output is correct
4 Correct 3 ms 20824 KB Output is correct
5 Correct 3 ms 20828 KB Output is correct
6 Correct 4 ms 20828 KB Output is correct
7 Correct 4 ms 20828 KB Output is correct
8 Correct 4 ms 20828 KB Output is correct
9 Correct 3 ms 20980 KB Output is correct
10 Correct 3 ms 20828 KB Output is correct
11 Correct 3 ms 20828 KB Output is correct
12 Correct 3 ms 21000 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 2396 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 2392 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 4444 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 4444 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 4 ms 20828 KB Output is correct
22 Correct 3 ms 20824 KB Output is correct
23 Correct 3 ms 20824 KB Output is correct
24 Correct 3 ms 20824 KB Output is correct
25 Correct 3 ms 20828 KB Output is correct
26 Correct 4 ms 20828 KB Output is correct
27 Correct 4 ms 20828 KB Output is correct
28 Correct 4 ms 20828 KB Output is correct
29 Correct 3 ms 20980 KB Output is correct
30 Correct 3 ms 20828 KB Output is correct
31 Correct 3 ms 20828 KB Output is correct
32 Correct 3 ms 21000 KB Output is correct
33 Correct 3 ms 20824 KB Output is correct
34 Correct 3 ms 20824 KB Output is correct
35 Correct 3 ms 20824 KB Output is correct
36 Correct 3 ms 20828 KB Output is correct
37 Correct 4 ms 20824 KB Output is correct
38 Correct 3 ms 20828 KB Output is correct
39 Correct 3 ms 20984 KB Output is correct
40 Correct 4 ms 20828 KB Output is correct
41 Correct 4 ms 20828 KB Output is correct
42 Correct 3 ms 20828 KB Output is correct
43 Correct 3 ms 21224 KB Output is correct
44 Correct 4 ms 20828 KB Output is correct
45 Correct 3 ms 20828 KB Output is correct
46 Correct 3 ms 20828 KB Output is correct
47 Correct 3 ms 20824 KB Output is correct
48 Correct 3 ms 20828 KB Output is correct
49 Correct 3 ms 20944 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 2396 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 2392 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 4444 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 4444 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 4 ms 20828 KB Output is correct
22 Correct 3 ms 20824 KB Output is correct
23 Correct 3 ms 20824 KB Output is correct
24 Correct 3 ms 20824 KB Output is correct
25 Correct 3 ms 20828 KB Output is correct
26 Correct 4 ms 20828 KB Output is correct
27 Correct 4 ms 20828 KB Output is correct
28 Correct 4 ms 20828 KB Output is correct
29 Correct 3 ms 20980 KB Output is correct
30 Correct 3 ms 20828 KB Output is correct
31 Correct 3 ms 20828 KB Output is correct
32 Correct 3 ms 21000 KB Output is correct
33 Correct 3 ms 20824 KB Output is correct
34 Correct 3 ms 20824 KB Output is correct
35 Correct 3 ms 20824 KB Output is correct
36 Correct 3 ms 20828 KB Output is correct
37 Correct 4 ms 20824 KB Output is correct
38 Correct 3 ms 20828 KB Output is correct
39 Correct 3 ms 20984 KB Output is correct
40 Correct 4 ms 20828 KB Output is correct
41 Correct 4 ms 20828 KB Output is correct
42 Correct 3 ms 20828 KB Output is correct
43 Correct 3 ms 21224 KB Output is correct
44 Correct 4 ms 20828 KB Output is correct
45 Correct 3 ms 20828 KB Output is correct
46 Correct 3 ms 20828 KB Output is correct
47 Correct 3 ms 20824 KB Output is correct
48 Correct 3 ms 20828 KB Output is correct
49 Correct 3 ms 20944 KB Output is correct
50 Correct 158 ms 148304 KB Output is correct
51 Correct 147 ms 157312 KB Output is correct
52 Correct 162 ms 170668 KB Output is correct
53 Correct 161 ms 170728 KB Output is correct
54 Correct 137 ms 185156 KB Output is correct
55 Correct 164 ms 167156 KB Output is correct
56 Correct 194 ms 178772 KB Output is correct
57 Correct 196 ms 168532 KB Output is correct
58 Correct 178 ms 157668 KB Output is correct
59 Correct 201 ms 182900 KB Output is correct
60 Correct 167 ms 186628 KB Output is correct
61 Correct 153 ms 186536 KB Output is correct
62 Correct 223 ms 123736 KB Output is correct
63 Correct 186 ms 124240 KB Output is correct
64 Correct 189 ms 124328 KB Output is correct
65 Correct 189 ms 126252 KB Output is correct
66 Correct 179 ms 126076 KB Output is correct
67 Correct 184 ms 124752 KB Output is correct
68 Correct 174 ms 124788 KB Output is correct
69 Correct 167 ms 125420 KB Output is correct
70 Correct 199 ms 124832 KB Output is correct
71 Correct 199 ms 124808 KB Output is correct
72 Correct 194 ms 125528 KB Output is correct