Submission #829261

# Submission time Handle Problem Language Result Execution time Memory
829261 2023-08-18T07:50:50 Z FatihSolak Catfish Farm (IOI22_fish) C++17
0 / 100
1000 ms 21880 KB
#include "fish.h"
#include <bits/stdc++.h>
using namespace std;

long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W){
	vector<pair<int,int>> v[N];
	vector<long long>pre[N];
	for(int i = 0;i<M;i++){
		v[X[i]].push_back({Y[i],W[i]});
	}
	for(int i = 0;i<N;i++){
		v[i].push_back({N+1,0});
		sort(v[i].begin(),v[i].end());
		pre[i].assign(v[i].size(),0);
		for(int j = 0;j<v[i].size();j++){
			pre[i][j] = v[i][j].second + (j?pre[i][j-1]:0);
		}
	}
    vector<pair<int,long long>> dp[N];
    dp[0].push_back({0,0});
    for(int i = 0;i<N;i++){
        vector<pair<int,long long>> ndp[N];
        for(int y = 0;y<N;y++){
            for(auto u:dp[y]){
                for(auto c:v[i]){
                    array<long long,3> nw;
                    nw[0] = u.first;
                    nw[1] = c.first-1;
                    nw[2] = u.second;
                    if(c.first - 1 <= u.first){
                        for(auto x:v[i]){
                            if(c.first-1 < x.first && x.first <= u.first)
                                nw[2] += x.second;
                        }
                    }
                    else{
                        if(i){
                            for(auto x:v[i-1]){
                                if(u.first < x.first && y < x.first && x.first <= c.first - 1)
                                    nw[2] += x.second;
                            }
                        }
                    }
                    ndp[nw[0]].push_back({nw[1],nw[2]});
                }
            }
        }
        for(int j = 0;j<N;j++){
            sort(ndp[j].begin(),ndp[j].end());
            vector<pair<int,long long>> tmp;
            for(auto u:ndp[j]){
                if(tmp.empty() || u.first != tmp.back().first)
                    tmp.push_back(u);
                else tmp.back().second = max(tmp.back().second,u.second);
            }
            ndp[j] = tmp;
            dp[j] = ndp[j];
        }
    }
    long long ans = 0;
    for(int i = 0;i<N;i++){
        for(auto c:dp[i]){
            ans = max(ans,c.second);
        }
    }
    return ans;
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:15:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   for(int j = 0;j<v[i].size();j++){
      |                 ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 21880 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1051 ms 15904 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 340 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1051 ms 15904 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1068 ms 21880 KB Time limit exceeded
2 Halted 0 ms 0 KB -