Submission #1065998

# Submission time Handle Problem Language Result Execution time Memory
1065998 2024-08-19T13:59:42 Z hasan2006 Catfish Farm (IOI22_fish) C++17
12 / 100
56 ms 9592 KB
#include <bits/stdc++.h>
//#include "fish.h"
using namespace std;

#define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define rall(s) s.rbegin(),s.rend()
#define all(s) s.begin(),s.end()
#define pb push_back
#define se second
#define fi first
#define ll long long
#define ld long double
#define YES cout<<"YES\n"
#define Yes cout<<"Yes\n"
#define yes cout<<"yes\n"
#define NO cout<<"NO\n"
#define No cout<<"No\n"
#define no cout<<"no\n"


const int N = 5e5+ 9 , mod = 1e9 + 7;
ll dp[N][2] ,  d[N];


ll max_weights(int n , int m , vector<int>a , vector<int>b , vector<int>c){
    ll q , i , j ,l ,r , x , y , s = 0 , f , k , mn = 1e18, mx = 0 ;

    for(i = 0; i < m; i++){
        d[a[i]] += c[i];
    }
    for(i = 0; i < n; i++){
        if(i == 0)
            dp[i][0] = 0 , dp[i][1] = 0 , dp[i][2] = 0;
        else
            dp[i][0] = max({dp[i - 1][1] , dp[i - 1][0] , dp[i - 1][2]}) ,dp[i][2] = dp[i - 1][1] + d[i],  dp[i][1] = max(dp[i - 1][0] +  d[i - 1], max(dp[i - 1][1] , dp[i - 1][2]));
    }
    return max({dp[n - 1][0] , dp[n - 1][1] , dp[n - 1][2]});
}

// Author : حسن

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:26:8: warning: unused variable 'q' [-Wunused-variable]
   26 |     ll q , i , j ,l ,r , x , y , s = 0 , f , k , mn = 1e18, mx = 0 ;
      |        ^
fish.cpp:26:16: warning: unused variable 'j' [-Wunused-variable]
   26 |     ll q , i , j ,l ,r , x , y , s = 0 , f , k , mn = 1e18, mx = 0 ;
      |                ^
fish.cpp:26:19: warning: unused variable 'l' [-Wunused-variable]
   26 |     ll q , i , j ,l ,r , x , y , s = 0 , f , k , mn = 1e18, mx = 0 ;
      |                   ^
fish.cpp:26:22: warning: unused variable 'r' [-Wunused-variable]
   26 |     ll q , i , j ,l ,r , x , y , s = 0 , f , k , mn = 1e18, mx = 0 ;
      |                      ^
fish.cpp:26:26: warning: unused variable 'x' [-Wunused-variable]
   26 |     ll q , i , j ,l ,r , x , y , s = 0 , f , k , mn = 1e18, mx = 0 ;
      |                          ^
fish.cpp:26:30: warning: unused variable 'y' [-Wunused-variable]
   26 |     ll q , i , j ,l ,r , x , y , s = 0 , f , k , mn = 1e18, mx = 0 ;
      |                              ^
fish.cpp:26:34: warning: unused variable 's' [-Wunused-variable]
   26 |     ll q , i , j ,l ,r , x , y , s = 0 , f , k , mn = 1e18, mx = 0 ;
      |                                  ^
fish.cpp:26:42: warning: unused variable 'f' [-Wunused-variable]
   26 |     ll q , i , j ,l ,r , x , y , s = 0 , f , k , mn = 1e18, mx = 0 ;
      |                                          ^
fish.cpp:26:46: warning: unused variable 'k' [-Wunused-variable]
   26 |     ll q , i , j ,l ,r , x , y , s = 0 , f , k , mn = 1e18, mx = 0 ;
      |                                              ^
fish.cpp:26:50: warning: unused variable 'mn' [-Wunused-variable]
   26 |     ll q , i , j ,l ,r , x , y , s = 0 , f , k , mn = 1e18, mx = 0 ;
      |                                                  ^~
fish.cpp:26:61: warning: unused variable 'mx' [-Wunused-variable]
   26 |     ll q , i , j ,l ,r , x , y , s = 0 , f , k , mn = 1e18, mx = 0 ;
      |                                                             ^~
fish.cpp:35:70: warning: array subscript 2 is above array bounds of 'long long int [2]' [-Warray-bounds]
   35 |             dp[i][0] = max({dp[i - 1][1] , dp[i - 1][0] , dp[i - 1][2]}) ,dp[i][2] = dp[i - 1][1] + d[i],  dp[i][1] = max(dp[i - 1][0] +  d[i - 1], max(dp[i - 1][1] , dp[i - 1][2]));
      |                                                           ~~~~~~~~~~~^
fish.cpp:35:82: warning: array subscript 2 is above array bounds of 'long long int [2]' [-Warray-bounds]
   35 |             dp[i][0] = max({dp[i - 1][1] , dp[i - 1][0] , dp[i - 1][2]}) ,dp[i][2] = dp[i - 1][1] + d[i],  dp[i][1] = max(dp[i - 1][0] +  d[i - 1], max(dp[i - 1][1] , dp[i - 1][2]));
      |                                                                           ~~~~~~~^
fish.cpp:35:179: warning: array subscript 2 is above array bounds of 'long long int [2]' [-Warray-bounds]
   35 |             dp[i][0] = max({dp[i - 1][1] , dp[i - 1][0] , dp[i - 1][2]}) ,dp[i][2] = dp[i - 1][1] + d[i],  dp[i][1] = max(dp[i - 1][0] +  d[i - 1], max(dp[i - 1][1] , dp[i - 1][2]));
      |                                                                                                                                                                        ~~~~~~~~~~~^
fish.cpp:33:50: warning: array subscript 2 is above array bounds of 'long long int [2]' [-Warray-bounds]
   33 |             dp[i][0] = 0 , dp[i][1] = 0 , dp[i][2] = 0;
      |                                           ~~~~~~~^
fish.cpp:37:58: warning: array subscript 2 is above array bounds of 'long long int [2]' [-Warray-bounds]
   37 |     return max({dp[n - 1][0] , dp[n - 1][1] , dp[n - 1][2]});
      |                                               ~~~~~~~~~~~^
# Verdict Execution time Memory Grader output
1 Correct 15 ms 3676 KB Output is correct
2 Correct 20 ms 4188 KB Output is correct
3 Correct 1 ms 1884 KB Output is correct
4 Correct 1 ms 1884 KB Output is correct
5 Correct 56 ms 9068 KB Output is correct
6 Correct 56 ms 9592 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1880 KB Output is correct
2 Correct 1 ms 1884 KB Output is correct
3 Correct 12 ms 3676 KB Output is correct
4 Correct 8 ms 3184 KB Output is correct
5 Correct 17 ms 4952 KB Output is correct
6 Correct 16 ms 4952 KB Output is correct
7 Correct 17 ms 4948 KB Output is correct
8 Correct 17 ms 4960 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1880 KB Output is correct
2 Correct 1 ms 1884 KB Output is correct
3 Correct 12 ms 3676 KB Output is correct
4 Correct 8 ms 3184 KB Output is correct
5 Correct 17 ms 4952 KB Output is correct
6 Correct 16 ms 4952 KB Output is correct
7 Correct 17 ms 4948 KB Output is correct
8 Correct 17 ms 4960 KB Output is correct
9 Incorrect 16 ms 4956 KB 1st lines differ - on the 1st token, expected: '99999', found: '66666'
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 3676 KB Output is correct
2 Correct 20 ms 4188 KB Output is correct
3 Correct 1 ms 1884 KB Output is correct
4 Correct 1 ms 1884 KB Output is correct
5 Correct 56 ms 9068 KB Output is correct
6 Correct 56 ms 9592 KB Output is correct
7 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '2', found: '1'
8 Halted 0 ms 0 KB -