Submission #1169142

#TimeUsernameProblemLanguageResultExecution timeMemory
1169142mateuszwesJelly Flavours (IOI20_jelly)C++20
54 / 100
685 ms197040 KiB
#include "jelly.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define ull unsigned ll #define pb push_back #define pii pair<int,int> #define pl pair<ll,ll> #define F first #define S second #define pq priority_queue #define all(x) x.begin(), x.end() #define deb(x) cout << #x << " = " << x << '\n'; #define deb2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << '\n'; //cena moze byc rowna 0 int find_maximum_unique(int x, int y, vector<int> a, vector<int> b) { int n = a.size(); if(x <= 500 && y <= 500 && n <= 200){ int dp[x+7][y+7][n+7]; for(int x1 = 0; x1 <= x; x1++){ for(int y1 = 0; y1 <= y; y1++){ dp[x1][y1][0] = 0; } } for(int x1 = 0; x1 <= x; x1++){ for(int y1 = 0; y1 <= y; y1++){ for(int i = 1; i <= n; i++){ dp[x1][y1][i] = dp[x1][y1][i-1]; if(x1 >= a[i-1]) dp[x1][y1][i] = max(dp[x1][y1][i], dp[x1-a[i-1]][y1][i-1]+1); if(y1 >= b[i-1]) dp[x1][y1][i] = max(dp[x1][y1][i], dp[x1][y1-b[i-1]][i-1]+1); } } } return dp[x][y][n]; } else if(y == 0){ int sc = 0; for(int i = 0; i < n; i++) if(b[i] == 0) a[i] = 0; sort(all(a)); int ind = 0; for(int i = 0; i < n; i++){ if(a[i] <= x){ x -= a[i]; sc++; } } return sc; } else{ int sc = 0; sort(all(a)); for(int i = 0; i < n; i++){ if(a[i] <= x){ x -= a[i]; sc++; } else if(b[i] <= y){ y -= b[i]; sc++; } } return sc; } return n; }
#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...