Submission #743490

#TimeUsernameProblemLanguageResultExecution timeMemory
743490MohamedAhmed04Akcija (COCI21_akcija)C++14
70 / 110
745 ms524288 KiB
#include <bits/stdc++.h> using namespace std ; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) ; long long rand(long long l , long long r) { return uniform_int_distribution<long long>(l , r)(rng) ; } const int MAX = 2010 ; int arr[MAX] ; int n , k ; vector< pair<int , int> >vp ; vector< array<long long , 3> >dp[MAX][MAX] ; bool cmp(array<long long , 3>&a , array<long long , 3>&b) { if(a[0] != b[0]) return (a[0] > b[0]) ; else return (a[1] < b[1]) ; } long long val[MAX] ; int main() { ios_base::sync_with_stdio(0) ; cin.tie(0) ; cin>>n>>k ; for(int i = 1 ; i <= n ; ++i) { int w , d ; cin>>w>>d ; vp.emplace_back(d , w) ; } for(int i = 1 ; i <= n ; ++i) val[i] = rand(1 , 1e12) ; vp.emplace_back(0 , 0) ; sort(vp.begin() , vp.end()) ; for(int i = 0 ; i <= n ; ++i) dp[0][i].push_back({0 , 0 , 0}) ; for(int i = 1 ; i <= n ; ++i) { dp[i][0] = dp[i-1][0] ; for(int j = 1 ; j <= n ; ++j) { dp[i][j] = dp[i-1][j] ; for(auto &a : dp[i][j-1]) dp[i][j].push_back(a) ; if(vp[j].first >= i) { for(auto &a : dp[i-1][j-1]) dp[i][j].push_back({a[0]+1 , a[1] + vp[j].second , a[2] + val[j]}) ; } sort(dp[i][j].begin() , dp[i][j].end() , cmp) ; dp[i][j].erase(unique(dp[i][j].begin() , dp[i][j].end()) , dp[i][j].end()) ; while(dp[i][j].size() > k) dp[i][j].pop_back() ; } } for(auto &a : dp[n][n]) cout<<a[0]<<" "<<a[1]<<"\n" ; return 0 ; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:62:26: warning: comparison of integer expressions of different signedness: 'std::vector<std::array<long long int, 3> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   62 |    while(dp[i][j].size() > k)
      |          ~~~~~~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...