# Problem solving

# Problem solving

vrotaru_md + 4 comments I'm looking at the second test case

5 1

5 3 4 5 6

And don't understand can it be solved in a day. We have 2 problems with the same difficulty level - 5.

Solving two problems with same difficulty in a day will be against the rules, right ?

nishant_304 + 0 comments [deleted]GrantDuan + 0 comments 5 in '5 3 4 5 6' do not mean difficulty.

ashwinscode + 1 comment It says that the two

**consecutive**problems that you solve in a given day should have a minimum difference of K in their vi ( and not every pair of problems that you solve in a given day)n=5, k=1; 5 3 4 5 6 is can be solved in a given day because that sequence has atleast a variation of 1 between consecutive numbers that is met.

However, if instead it was n=3, k=1; 5 5 6, then you need minimum 2 days to solve it.

pazdaniel7 + 1 comment It also mentions that the difficulty of problems within a same day must increase . So you cannot solve 3 4 5 5 6 in that order on a same day, because you are not increasing difficulty from 5 to 5. Therefore, I have the same doubt, seems like you need 2 days to solve the second example for me too.

reyvaj64 + 0 comments I can only assume that: " Problems with similar vi values are similar in nature" means you can solve all fives at the same time, but that might be stretching it

fengyuxue11011 + 0 comments it's a weird problem. Hard to understand.

[deleted] + 1 comment Its really hard to understand the question. Can anyone please tell me what actually i have to do?

asattar + 0 comments the first line of the input which is 2 represent 2 problems the first is: 3 2 5 4 7 {3 2} 3 is the number of cases in problem one which are 5 4 7 and 2 is the minimum differnce to solve cosecutive and 2nd

3 2

5 4 7

pb1038 + 1 comment testcase #1 [113 , 128]

Expected output is 5, where as my solution solves in 3 dayz. And seems correct to me..

Day 1 :: 383 694 335 335 160 986 355 762 973 542 717 853 663 483 218 16 507 852 365 791 264 492 173 38 538 860 281 988 857 591 342 971 353 666 512 70 518 362 84 352 113 301 507 639 365 33 876 680 142 413 970 637 171 957 761 466 315 887 184 40 970 536 153 622 394 791 290 110 632 265 736 549 296 878 314 834 199 950 356 156 794 469 157 961 824 287 678 141

Day 2 :: 422 422 958 763 400 155 829 668 490 155 539 845 650 815 327 674 934 172 359

Day 3 :: 440 851 174 872 105 246

Am I missing any constraint??

Fluffy_Bunny + 0 comments 335 appears twice in a row in day 1, and 422 does the same in day 2. Not valid when you have k=128.

kanchanpatel2606 + 0 comments # include

# include

# include

# include

# include

using namespace std;

int t, n, v[300], k, match[300], visited[300];

bool dfs(int s) { if(visited[s]) return false; visited[s] = true; for(int i = s + 1; i < n; i ++) if(abs(v[i] - v[s]) >= k) if(match[i] == -1 || dfs(match[i])) { match[i] = s; return true; } return false; }

int main() { for(cin >> t; t--; ) { cin >> n >> k; for(int i = 0; i < n; i ++) cin >> v[i]; memset(match, -1, sizeof match); int result = n; for(int i = 0; i < n; i ++) { memset(visited, 0, sizeof visited); if(dfs(i)) result -= 1; } cout << result << endl; } return 0; }

Sort 28 Discussions, By:

Please Login in order to post a comment