Please subscribe to the official Codeforces channel in Telegram via the link https://t.me/codeforces_official. ×

noobCoderUltraProMax's blog

By noobCoderUltraProMax, history, 18 months ago, In English

Problem Link:https://codeforces.com/contest/1779/problem/D

Code Link:https://codeforces.com/contest/1779/submission/189809516

Logic: i am using: first i am handling No case when v1[i]<v2[i], then i am storing count of all razors in a map. Now i iterate through 0 to n-1 and check if v1[i]>v2[i] if it so then i check if it the first time i have encountered this element, if yes then i need to use razor so i do mp[v2[i]]-- and update its position in other map, if it is not the first time then i range query from last position where i have seen that element to current position for max element. if it is greater than current element then i use razor an if it any moment mp[v2[i]] is required but it is 0 then i set bool flag var to false.

Difficulty: i am getting WA on test case 2 sub-test 252.

Edit: i found the bug.

| Write comment?