Submission #1049335

# Submission time Handle Problem Language Result Execution time Memory
1049335 2024-08-08T16:39:43 Z modwwe Catfish Farm (IOI22_fish) C++17
100 / 100
97 ms 42320 KB
//https://www.instagram.com/_modwwe/
#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".ans","w",stdout)
#define pb push_back
#define checktime   cerr << (double)clock() / CLOCKS_PER_SEC * 1000  << " ms";
using namespace std;
void phongbeo();
const ll inf=1e18;
const int mod2=1e9+7;
const int  mod1=998244353;
struct icd
{
    long double a;
    int b;
};
struct ib
{
    ll a;
    ll b;
};
struct ic
{
    int a,b,c;
};
struct id
{
    int a,b,c,d;
};
struct ie
{
    int a,b,c,d,e;

};

ll n,m,s1,s2,s4,s3,sf,k,s5,s6,mx,s7,s8,s9,mx2,res,dem2=0,dem=0,s33,dem3,l,r,mid;
int  i,s10,s12;
int kk;
int el=29;
/*
main()
{
#ifndef ONLINE_JUDGE
  fin(task),fou(task);
#endif
   //  NHP
    /// cin>>s1;
    //  modwwe
    phongbeo();
}*/
vector<ib> v[100001];
bool cmp(ib a,ib b)
{
    return a.a<b.a;
}
ll max_weights(int n, int m, vector<int> X, vector<int> Y, vector<int> W)
{
    for(int i=0; i<m; i++)
        v[X[i]+1].pb({Y[i]+1,W[i]});
vector<ll> dp[n+1][2];
    for(int i=1; i<=n; i++)
    {
        v[i].pb({n+1,0});
        sort(v[i].begin(),v[i].end(),cmp);
        dp[i][0].resize(v[i].size()+2);
        dp[i][1].resize(v[i].size()+2);
    }
    for(int i=1;i<=1;i++)
        for(int j=v[i].size()-1;j>=0;--j)
         dp[i][0][j]=-inf;
    for(int i=1; i<=n; i++)
    {
        for(int j=v[i].size()-2; j>=0; j--)
           dp[i][0][j]=max(dp[i][0][j+1],dp[i][0][j])+v[i][j].b,s6=max(s6,dp[i][0][j]);
        l=0;
        dem=0;
        s2=0;
        s3=0;
        if(i!=1){
          //      cout<<i,down
            for(auto x:v[i])
            {
                while(x.a-1>=v[i-1][l].a)
                    s3+=v[i-1][l].b,l++;
                dp[i][1][dem]=max({dp[i][1][dem],s4,dp[i-1][1][l]+s3});
                dem++;
            }
           //  cout<<i,down
            }
        dem=0;
        s4=0;
        l=0;
        if(i!=n){
            // cout<<i,down
            for(auto x:v[i])
            {
                while(x.a-1>=v[i+1][l].a)
                    l++;
                    if(l!=0){
                 //cout<<v[i].size()<<" "<<dem<<" "<<max(dp[i][1][dem],dp[i][0][dem])<<" "<<dp[i+1][0][l-1],down
                dp[i+1][0][l-1]=max({dp[i+1][0][l-1],dp[i][1][dem],dp[i][0][dem]});
                }
                s4=max({s4,dp[i][0][dem],dp[i][1][dem]});
                dem++;
            }
            //cout<<i,down
            }
        s5=v[i][0].b;
        s6=max(s6,dp[i][1][0]);
        for(int j=1; j<v[i].size(); j++)
        {s6=max(s6,dp[i][1][j]);
            dp[i][1][j]=max(dp[i][1][j]-s5,dp[i][1][j-1]);
            s5+=v[i][j].b;
        }
    }
     return s6;
}
/*
void phongbeo()
{
     cin>>n>>m;
     vector<int> x(m);
      vector<int> y(m);
       vector<int> w(m);
      for(int i=0;i<m;i++)
 	cin >> x[i] >> y[i] >> w[i];
      cout<<max_weights(n,m,x,y,w);
     }*/

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:107:17: warning: this 'while' clause does not guard... [-Wmisleading-indentation]
  107 |                 while(x.a-1>=v[i+1][l].a)
      |                 ^~~~~
fish.cpp:109:21: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'while'
  109 |                     if(l!=0){
      |                     ^~
fish.cpp:120:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<ib>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  120 |         for(int j=1; j<v[i].size(); j++)
      |                      ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 31 ms 21188 KB Output is correct
2 Correct 36 ms 24000 KB Output is correct
3 Correct 18 ms 16732 KB Output is correct
4 Correct 17 ms 16700 KB Output is correct
5 Correct 88 ms 39656 KB Output is correct
6 Correct 86 ms 42320 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2648 KB Output is correct
2 Correct 49 ms 27112 KB Output is correct
3 Correct 58 ms 31308 KB Output is correct
4 Correct 35 ms 21216 KB Output is correct
5 Correct 37 ms 24000 KB Output is correct
6 Correct 1 ms 2648 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2652 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 16 ms 16868 KB Output is correct
11 Correct 15 ms 16732 KB Output is correct
12 Correct 30 ms 21136 KB Output is correct
13 Correct 37 ms 24032 KB Output is correct
14 Correct 31 ms 21168 KB Output is correct
15 Correct 34 ms 23228 KB Output is correct
16 Correct 31 ms 21120 KB Output is correct
17 Correct 34 ms 23228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 16728 KB Output is correct
2 Correct 15 ms 16732 KB Output is correct
3 Correct 25 ms 19984 KB Output is correct
4 Correct 24 ms 19976 KB Output is correct
5 Correct 38 ms 26288 KB Output is correct
6 Correct 39 ms 25676 KB Output is correct
7 Correct 39 ms 26340 KB Output is correct
8 Correct 41 ms 26188 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2796 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2788 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2788 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 2 ms 2908 KB Output is correct
11 Correct 1 ms 2908 KB Output is correct
12 Correct 1 ms 2912 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2796 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2788 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2788 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 2 ms 2908 KB Output is correct
11 Correct 1 ms 2908 KB Output is correct
12 Correct 1 ms 2912 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2856 KB Output is correct
16 Correct 1 ms 2908 KB Output is correct
17 Correct 10 ms 5980 KB Output is correct
18 Correct 10 ms 6744 KB Output is correct
19 Correct 10 ms 6640 KB Output is correct
20 Correct 10 ms 6424 KB Output is correct
21 Correct 10 ms 6492 KB Output is correct
22 Correct 19 ms 10320 KB Output is correct
23 Correct 3 ms 3416 KB Output is correct
24 Correct 7 ms 4924 KB Output is correct
25 Correct 1 ms 2908 KB Output is correct
26 Correct 4 ms 3252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB Output is correct
2 Correct 1 ms 2796 KB Output is correct
3 Correct 1 ms 2652 KB Output is correct
4 Correct 1 ms 2652 KB Output is correct
5 Correct 1 ms 2652 KB Output is correct
6 Correct 1 ms 2788 KB Output is correct
7 Correct 1 ms 2652 KB Output is correct
8 Correct 1 ms 2788 KB Output is correct
9 Correct 1 ms 2652 KB Output is correct
10 Correct 2 ms 2908 KB Output is correct
11 Correct 1 ms 2908 KB Output is correct
12 Correct 1 ms 2912 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2856 KB Output is correct
16 Correct 1 ms 2908 KB Output is correct
17 Correct 10 ms 5980 KB Output is correct
18 Correct 10 ms 6744 KB Output is correct
19 Correct 10 ms 6640 KB Output is correct
20 Correct 10 ms 6424 KB Output is correct
21 Correct 10 ms 6492 KB Output is correct
22 Correct 19 ms 10320 KB Output is correct
23 Correct 3 ms 3416 KB Output is correct
24 Correct 7 ms 4924 KB Output is correct
25 Correct 1 ms 2908 KB Output is correct
26 Correct 4 ms 3252 KB Output is correct
27 Correct 2 ms 3672 KB Output is correct
28 Correct 46 ms 20288 KB Output is correct
29 Correct 66 ms 26784 KB Output is correct
30 Correct 71 ms 26520 KB Output is correct
31 Correct 66 ms 26644 KB Output is correct
32 Correct 61 ms 27676 KB Output is correct
33 Correct 71 ms 26712 KB Output is correct
34 Correct 71 ms 26524 KB Output is correct
35 Correct 25 ms 12376 KB Output is correct
36 Correct 62 ms 27916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 15 ms 16728 KB Output is correct
2 Correct 15 ms 16732 KB Output is correct
3 Correct 25 ms 19984 KB Output is correct
4 Correct 24 ms 19976 KB Output is correct
5 Correct 38 ms 26288 KB Output is correct
6 Correct 39 ms 25676 KB Output is correct
7 Correct 39 ms 26340 KB Output is correct
8 Correct 41 ms 26188 KB Output is correct
9 Correct 39 ms 26168 KB Output is correct
10 Correct 32 ms 17900 KB Output is correct
11 Correct 63 ms 33040 KB Output is correct
12 Correct 1 ms 2648 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 1 ms 2652 KB Output is correct
17 Correct 1 ms 2652 KB Output is correct
18 Correct 14 ms 16868 KB Output is correct
19 Correct 15 ms 16868 KB Output is correct
20 Correct 15 ms 16732 KB Output is correct
21 Correct 16 ms 16732 KB Output is correct
22 Correct 38 ms 25680 KB Output is correct
23 Correct 71 ms 33420 KB Output is correct
24 Correct 64 ms 33616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 21188 KB Output is correct
2 Correct 36 ms 24000 KB Output is correct
3 Correct 18 ms 16732 KB Output is correct
4 Correct 17 ms 16700 KB Output is correct
5 Correct 88 ms 39656 KB Output is correct
6 Correct 86 ms 42320 KB Output is correct
7 Correct 1 ms 2648 KB Output is correct
8 Correct 49 ms 27112 KB Output is correct
9 Correct 58 ms 31308 KB Output is correct
10 Correct 35 ms 21216 KB Output is correct
11 Correct 37 ms 24000 KB Output is correct
12 Correct 1 ms 2648 KB Output is correct
13 Correct 1 ms 2652 KB Output is correct
14 Correct 1 ms 2652 KB Output is correct
15 Correct 1 ms 2652 KB Output is correct
16 Correct 16 ms 16868 KB Output is correct
17 Correct 15 ms 16732 KB Output is correct
18 Correct 30 ms 21136 KB Output is correct
19 Correct 37 ms 24032 KB Output is correct
20 Correct 31 ms 21168 KB Output is correct
21 Correct 34 ms 23228 KB Output is correct
22 Correct 31 ms 21120 KB Output is correct
23 Correct 34 ms 23228 KB Output is correct
24 Correct 15 ms 16728 KB Output is correct
25 Correct 15 ms 16732 KB Output is correct
26 Correct 25 ms 19984 KB Output is correct
27 Correct 24 ms 19976 KB Output is correct
28 Correct 38 ms 26288 KB Output is correct
29 Correct 39 ms 25676 KB Output is correct
30 Correct 39 ms 26340 KB Output is correct
31 Correct 41 ms 26188 KB Output is correct
32 Correct 1 ms 2652 KB Output is correct
33 Correct 1 ms 2796 KB Output is correct
34 Correct 1 ms 2652 KB Output is correct
35 Correct 1 ms 2652 KB Output is correct
36 Correct 1 ms 2652 KB Output is correct
37 Correct 1 ms 2788 KB Output is correct
38 Correct 1 ms 2652 KB Output is correct
39 Correct 1 ms 2788 KB Output is correct
40 Correct 1 ms 2652 KB Output is correct
41 Correct 2 ms 2908 KB Output is correct
42 Correct 1 ms 2908 KB Output is correct
43 Correct 1 ms 2912 KB Output is correct
44 Correct 1 ms 2652 KB Output is correct
45 Correct 1 ms 2652 KB Output is correct
46 Correct 1 ms 2856 KB Output is correct
47 Correct 1 ms 2908 KB Output is correct
48 Correct 10 ms 5980 KB Output is correct
49 Correct 10 ms 6744 KB Output is correct
50 Correct 10 ms 6640 KB Output is correct
51 Correct 10 ms 6424 KB Output is correct
52 Correct 10 ms 6492 KB Output is correct
53 Correct 19 ms 10320 KB Output is correct
54 Correct 3 ms 3416 KB Output is correct
55 Correct 7 ms 4924 KB Output is correct
56 Correct 1 ms 2908 KB Output is correct
57 Correct 4 ms 3252 KB Output is correct
58 Correct 2 ms 3672 KB Output is correct
59 Correct 46 ms 20288 KB Output is correct
60 Correct 66 ms 26784 KB Output is correct
61 Correct 71 ms 26520 KB Output is correct
62 Correct 66 ms 26644 KB Output is correct
63 Correct 61 ms 27676 KB Output is correct
64 Correct 71 ms 26712 KB Output is correct
65 Correct 71 ms 26524 KB Output is correct
66 Correct 25 ms 12376 KB Output is correct
67 Correct 62 ms 27916 KB Output is correct
68 Correct 39 ms 26168 KB Output is correct
69 Correct 32 ms 17900 KB Output is correct
70 Correct 63 ms 33040 KB Output is correct
71 Correct 1 ms 2648 KB Output is correct
72 Correct 1 ms 2652 KB Output is correct
73 Correct 1 ms 2652 KB Output is correct
74 Correct 1 ms 2652 KB Output is correct
75 Correct 1 ms 2652 KB Output is correct
76 Correct 1 ms 2652 KB Output is correct
77 Correct 14 ms 16868 KB Output is correct
78 Correct 15 ms 16868 KB Output is correct
79 Correct 15 ms 16732 KB Output is correct
80 Correct 16 ms 16732 KB Output is correct
81 Correct 38 ms 25680 KB Output is correct
82 Correct 71 ms 33420 KB Output is correct
83 Correct 64 ms 33616 KB Output is correct
84 Correct 81 ms 38084 KB Output is correct
85 Correct 82 ms 38916 KB Output is correct
86 Correct 91 ms 40580 KB Output is correct
87 Correct 97 ms 42064 KB Output is correct
88 Correct 1 ms 2652 KB Output is correct
89 Correct 90 ms 42140 KB Output is correct
90 Correct 83 ms 40788 KB Output is correct
91 Correct 81 ms 40784 KB Output is correct