By Vladosiya, history, 6 months ago,

1714A - Everyone Loves to Sleep

Tutorial
Solution

1714B - Remove Prefix

Idea: MikeMirzayanov

Tutorial
Solution

1714C - Minimum Varied Number

Idea: MikeMirzayanov

Tutorial
Solution

1714D - Color with Occurrences

Idea: MikeMirzayanov

Tutorial
Solution

Idea: DmitriyOwlet

Tutorial
Solution

1714F - Build a Tree and That Is It

Idea: MikeMirzayanov

Tutorial
Solution

1714G - Path Prefixes

Idea: MikeMirzayanov

Tutorial
Solution

• +22

 » 6 months ago, # |   0 Good editorial!
•  » » 6 months ago, # ^ |   -45 yes its such a good one! :D thanks op for the editorial
 » 6 months ago, # |   +23 Code for D is messed up a bit.
•  » » 6 months ago, # ^ |   0 yes
•  » » 6 months ago, # ^ |   0 Here is a better intuitive solution. Solution#include "bits/stdc++.h" using namespace std; void solve() { string t; cin >> t; int n; cin >> n; vector s(n); for (auto &ele : s) cin >> ele; vector> ans; int l = -1, r = 0; for (int i = 0; i < t.size(); i++) { int tempr = (-1), templ, ind; for (int j = l + 1; j <= r; j++) { for (int k = 0; k < n; k++) { if (t.substr(j, s[k].size()) == s[k]) { if (tempr < (int)(j + s[k].size())) { tempr = (j + s[k].size()); templ = j; ind = k; } } } } if (tempr == (-1)) { cout << -1 << endl; return; } else { ans.push_back({ind + 1, templ + 1}); r = i = tempr; i--; l = templ; } } cout << ans.size() << endl; for (auto &ele : ans) { cout << ele.first << " " << ele.second << endl; } } int main() { int T = 1; cin >> T; while (T--) { solve(); } return 0; } 166883799
•  » » 6 months ago, # ^ |   0 I implemented it in an easier way. My Submissionvoid solve() { string s; int n, len = size(s); cin >> s >> n; vector v(n); cin >> v; vii ans; int last = 0; while (last != size(s)) { int id = -1, cur = last; rep(i, 0, n) { int j = last, k = size(v[i]); while (j >= 0 and last - j < k) { if (size(s) - j >= k and s.substr(j, k) == v[i] and cur < j + k) cur = j + k, id = i; j--; } } if (id == -1) { cout << -1 << endl; return; } ans.pb({id, cur - size(v[id])}); last = cur; } cout << size(ans) << endl; for (auto &e : ans) cout << e.ff + 1 << " " << e.ss + 1 << endl; } 
•  » » » 6 months ago, # ^ |   0 Could you please share your idea?
•  » » » 6 months ago, # ^ |   0 hey man i sort of did the same implementation as yours, but I'm getting MLE, can you please tell me why ? D
 » 6 months ago, # |   0 Mike Mirzayanov thanks for awesome editorial
•  » » 6 months ago, # ^ |   0 Idk, awesome editorial in my understanding contains much more detailed and intuitive solutions with hints, this one is just ok.
 » 6 months ago, # |   +15 Question D is a great problem,but why is the code for D so messy？
 » 6 months ago, # |   0 Hey, can anyone tell me why did I get a MLE on D with submission 166572453? I precomputed every segment that can be painted in one step, however there can at most be 100*10 such segments for every test case. If every segment is 3 integers (12 bytes) then they use at most 12000 bytes of memory. Lets say that I copy all segments once into final, then I use at most 2*12000=24000 bytes per test case. This is way below the 256 MB memory limit, so why did my solution get MLE? Thanks.
 » 6 months ago, # |   0 How to solve question D with DP? Can you tell me about it and share your code? If you can help me, I will thank you very much.
•  » » 6 months ago, # ^ |   0 Here is my solution: 166798483
•  » » » 6 months ago, # ^ |   0 What does your dp[i] mean？
•  » » » » 6 months ago, # ^ |   0 dp[i] is the minimum number of steps needed to color prefix(length is i) of text t in red.use[i]: If an operation was done at a certain location, I recorded the selected subscript.from[i]: Otherwise I recorded which operation the location was affected by.
•  » » » » » 6 months ago, # ^ |   0 thanks
•  » » » » 6 months ago, # ^ |   -9 dp is an array and i is the element position in the array
•  » » » » » 6 months ago, # ^ |   0 wth is this shit man. Stop it
•  » » » » » 6 months ago, # ^ |   0 This comment does not have enough downvotes for destroying almost the entire comment section of the editorial.
 » 6 months ago, # |   +10 Indented solution of problem D from editorial: Solution#include #define len(s) (int)s.size() #define forn(i, n) for (int i = 0; i < int(n); i++) using namespace std; int ans = 0; bool ok = true; void Find(int a, int b, string &t, vector&str, vector>&match){ int Max = 0, id = -1, pos = -1; for(int i = a; i <= b; i++){ for(int j = 0; j < len(str); j++){ string s = str[j]; if(i + len(s) > len(t) || i + len(s) <= b)continue; if(t.substr(i, len(s)) == s) { if(i + len(s) > Max){ Max = i + len(s); id = j; pos = i; } } } } if(id == -1) { ok = false; return; } else { match.emplace_back(id, pos); ans++; if(Max == len(t)) return; else Find(max(pos + 1, b +1), Max, t, str, match); } } void solve(){ ans = 0; ok = true; string t; cin >> t; int n; cin >> n; vectors(n); vector>match; forn(i, n) { cin >> s[i]; } Find(0, 0, t, s, match); if(!ok) cout << "-1\n"; else{ cout << ans << endl; for(auto &p : match) cout << p.first + 1 << ' ' << p.second + 1 << endl; } } int main(){ int q; cin >> q; while(q--){ solve(); } return 0; } 
 » 6 months ago, # |   0 "When you color a letter in red again, it stays red."Missed this line during contest does this make the question similar to Jump game? ->where we can jump from index to any index in range (i,i+a[i])
•  » » 5 months ago, # ^ |   +1 Yes essentially the same problem. Here's my implementation using this idea.https://codeforces.com/contest/1714/submission/169954163
 » 6 months ago, # |   0 Can someone help me out with my wa for E? https://codeforces.com/problemset/submission/1714/166799175Approach: I move the highest number to a remainder of 8 Everything else can either reach the number or not, and I set conditions for it. For i in (0, n - 1) Let k = a[i] / 10, l = a[max] / 10 if remainder = 1, 2, 4, 8 then (l - k) % 2 = 0 if remainder = 3, 6, 7, 9 then (l - k) % 2 = 1 if remainder = 5, a[i] + 5 == a[max] if remainder = 0, a[i] == a[max] else return NO 
•  » » 6 months ago, # ^ |   0 Take a look at Ticket 15975 from CF Stress for a counter example.
 » 6 months ago, # |   +3 The code for F: Build a Tree and That is it does not really clarify things mentioned in tutorial rather it has checks and implementations that makes it seem like the code to be working on a different idea. Can anyone either explain the tutorial or the code ? Thanks.
•  » » 6 months ago, # ^ |   0 Can you help me with G.I checked ur code, but can't understand, Can u explain ur idea ? Thanks.
•  » » » 6 months ago, # ^ |   +3 So, let's first make a DFS call and make array Asum[N], where Asum[u] stores the sum of all the A-values along the edges from root to node u.Now notice that B values of all edges are positive. Let's pick any node u. And let's say, Path[u] = [B1, B2, B3, B4, B5,.....Bx] where the Bi indicates the B-values of all edges from root to node u.Since Bi s are positive the prefix sum on Path[u] will only increase. Let's call the prefix sum on Path[u] as PrefixPath[u].Since we want to know maximum prefix path that doesnt go beyond all A values sum in the path from root to u, the final answer for node u will beAnswer[u] = Largest index k in PrefixPath[u] such that PrefixPath[k] > Asum[u].
•  » » 6 months ago, # ^ |   +6 I can explain my idea of solution if it can help you.Let's place $1,2$ and $3$ nodes. There is $4$ possible ways to do it: link to image The first case: $d_{23} = d_{31} + d_{12}$. Let's check it, if it is right, then let's build our tree like in image. The second case: $d_{31} = d_{23} + d_{12}$. Let's check it, if it is right, then let's build our tree like in image. The third case: $d_{12} = d_{23} + d_{31}$. Let's check it, if it is right, then let's build our tree like in image. The last case: let's see that $d_{12} + d_{23} + d_{31} \le n$, let's get loop for $d_{14} = [1..n]$ (sum of $n$ for all cases is $\le 10^5$ so we can do it), now we know $d_{34} = d_{31} - d_{14}$ etc. If all this right, then let's build our tree like in image. If all cases are wrong, answer is NO.
•  » » » 6 months ago, # ^ |   +3 Woah...Thank you so much. The image actually made your idea very clear. upvote_plus_plus
 » 6 months ago, # |   0 It was a very good contest D was interesting but i think you should reorder the problem like this B C A E D G F
•  » » 6 months ago, # ^ |   0 B C A E G D F
•  » » » 6 months ago, # ^ |   0 B C A D E G F
 » 6 months ago, # |   0 I read the solution "Thus, we will apply the operation to each element of the array until its remainder modulo 10 becomes, for example, 2, and then check that the array does not contain both remainders 2 and 12 modulo 20." I don't know why do we need to check that "the aray does not contain both remainders 2 and 12 modulo 20". Why do we have to do that. Can you explain for me. Thanks
•  » » 6 months ago, # ^ |   0 There are only 2 possible cycles when considered modulo 20 (2 -> 4 -> 8 -> 16 -> 2) and (12 -> 14 -> 18 -> 6 -> 12). If members of both cycles are present, you can never make all the numbers the same.
•  » » » 6 months ago, # ^ |   0 Oh wow, thank you expert
•  » » 6 months ago, # ^ | ← Rev. 2 →   0 we also can apply operation until we get either 2 or 4 or 6 or 8 as remainder of 10 from each (as all element eventually add-up and give even output) and then we can do same process ( which is checking whether array contain all same element)if we choose 2 all element will be 12 or 2 // while propagating (3,6,7,9) we can get 12 after some operation while changing element to module 20for 3's propagation ->3 6 12 14 18 26 32 34 38 46 ->>(%20)->> 3 6 12 14 18 6 12 14 18 6for 6's propagation ->6 12 14 18 26 3 34 328 46->>(%20)->> 6 12 14 18 6 12 14 18 6for 7's propagation ->7 14 18 26 32 34 38 46 ->>(%20)->> 7 14 18 6 12 14 18 6for 9's propagation ->9 18 26 32 34 38 46 52 ->>(%20)->> 9 18 6 12 14 18 6 12for other numbers (1,2,4,8) we can get 2 after some operation while changing element to module 20for 1's propagation ->1 2 4 8 16 22 24 28 36 42->>(%20)->> 1 2 4 8 16 2 4 8 16 2for 2's propagation ->2 4 8 16 22 24 28 36 42->>(%20)->> 2 4 8 16 2 4 8 16 2for 4's propagation ->4 8 16 22 24 28 36 42->>(%20)->> 4 8 16 2 4 8 16 2for 8's propagation ->8 16 22 24 28 36 42->>(%20)->> 8 16 2 4 8 16 2mark we can get 2 for (1,2,4,8) but we can't get 12 and similarly we can get 12 for (3,6,7,9) but we can't get 2;mark in similar way we can get 4 for (1,2,4,8) not 14 and we can get 14 for(3,6,7,9) not 4so change all element to either 2 or 4 or 6 or 8 you will end up having either (2,12) or (4,14) or (6,16) or (8,18) respectively and then check whether all same or not answer accordinglyif 5 and 0 as (%10) present we need to check them separately either all same who having 0 as (%10) and if 5 present all should be 5 less from all element who are having 0 as (%10);
•  » » » 6 months ago, # ^ |   0 Wow. Thanks a lot <3
 » 6 months ago, # |   0 How to solve C using dp ??
•  » » 6 months ago, # ^ |   0 Do you mean problem D?
•  » » » 6 months ago, # ^ |   0 No, I am trying to solve C using dp. But I am getting wrong answers. This is my code : Its a link to Tutorial point compilerhttp://tpcg.io/_28VQ7L
 » 6 months ago, # |   0 Problem D and E were very nice But I think problem E is much easier than D.
•  » » 6 months ago, # ^ |   0 Problem F is also very nice and I think problem F is easier than D and E because I successfully passed F in the contest but failed to pass D and E.
 » 6 months ago, # |   0 Code for $Problem D$ should be posted like this : Solution #include #define len(s) (int)s.size() #define forn(i, n) for (int i = 0; i < int(n); i++) using namespace std; int ans = 0; bool ok = true; void Find(int a, int b, string &t, vector&str, vector>&match) { int Max = 0, id = -1, pos = -1; for(int i = a; i <= b; i++) { for(int j = 0; j < len(str); j++) { string s = str[j]; if (i + len(s) > len(t) || i + len(s) <= b) continue; if (t.substr(i, len(s)) == s) { if (i + len(s) > Max){ Max = i + len(s); id = j; pos = i; } } } if(id == -1) { ok = false; return; } else { match.emplace_back(id, pos); ans++; if (Max == len(t)) return; else Find(max(pos + 1, b +1), Max, t, str, match); } } void solve() { ans = 0; ok = true; string t; cin >> t; int n; cin >> n; vectors(n); vector>match; forn(i, n) { cin >> s[i]; } Find(0, 0, t, s, match); if(!ok) cout << "-1\n"; else{ cout << ans << endl; for(auto &p : match) cout << p.first + 1 << ' ' << p.second + 1 << endl; } } int main(){ int q; cin >> q; while(q--){ solve(); } return 0; } I think Vladosiya has forgotten to write  at the end.
•  » » 6 months ago, # ^ |   +1 Thanks for tagging, Fixed
 » 6 months ago, # |   0 Does anybody have E wa3 ,only one line of code was different between the two submissions Submissions id(wa3) : 166896597 Submissions id(ac) : 166900206 I'd like to know what the problem is. Could you please take a look at it for me，thanks！！！！！
•  » » 6 months ago, # ^ |   0 Take a look at Ticket 15979 from CF Stress for a counter example.
•  » » » 6 months ago, # ^ |   0 thanks a lot！！！
 » 6 months ago, # | ← Rev. 3 →   0 G is not that hard compared to F, Dagree?
 » 6 months ago, # |   0 Problem D can be also done with DP approach: 166555787
•  » » 6 months ago, # ^ |   0 can you please explain your approach .
 » 6 months ago, # |   0 It took some time for me but I solved it finally :)I started by stating out the different series that are being made and what commonalities they have. I deduced that there are two disjoint sets (if you exclude the multiples of 5 of which there are several disjoint sets.) that you get. I called the set {1,2,4,8,16,22,24,...,96} for evenSet. And the set {3, 6, 12, 14, 18, 26, ..., 98} for oddSet.The trick is to know that it's only the last two digits in every number which denotes which set it belongs to. For example 111 is equivalent to 11 in the series since they can converge.What about prime numbers like 17? For them, we can see that 17 + 17 % 10 = 24 is a member of the evenSet. This is true for all such numbers, we can just check if either the number or the next number of the series of the current number is in the set we're interested to check.What about multiples of 5? For them, we know that {5, 10} is one set, {15,20} another. The set cannot increase and thus we only need to worry about checking if all numbers are equal to the latter in the set. i.e. if a % 10 == 5, then we should look for a + 5. But note that we will check for all other numbers b, if b == a or b+5==a.Once we have this, the solution should be quite straightforward: Generate the evenSet and the oddSet. Check if there are any multiples of 5, if so then we know that all of them should be in the same multiples set. If there were not any multiples of 5, then check if a or a + a%10 is in the evenSet or the oddSet. (Only take the last two digits of the number!). If there are already any in the oddSet, then since the sets are disjoint, then we know there are no way to make them equal. Similarly, we check in the oddSet and if there are any in the evenSet. Took a bit of time but well worth it, learned a lot. Can probably be cleaned up a lot: import java.util.HashSet; import java.util.Scanner; public class E { public static void main(String[] args) { Scanner input = new Scanner(System.in); int t = input.nextInt(); while (t > 0) { solution(input); t--; } } public static void solution(Scanner input) { int n = input.nextInt(); int[] a = new int[n]; String result = "Yes"; boolean odds = false; boolean evens = false; boolean fives = false; HashSet evenSet = new HashSet<>(); HashSet oddSet = new HashSet<>(); for (int i = 0; i < n; i++) { a[i] = input.nextInt(); } // 1. Generate even sets: {1,2,4,8} etc. A member or the member + member % 10 counts. int firstEven = 1; while (firstEven < 100) { evenSet.add(firstEven); firstEven += firstEven % 10; } int firstOdd = 3; while (firstOdd < 100) { oddSet.add(firstOdd); firstOdd += firstOdd % 10; } // 2. Check if multiple of 5. int target = 0; for (int e : a) { if (e % 10 == 5) { if (fives && (e + 5) != target) { result = "No"; break; } if (target == 0) { target = e + 5; } fives = true; } if (e % 10 == 0) { if (fives && e != target) { result = "No"; break; } if (target == 0) { target = e; } fives = true; } } // 3. Check in odd and even sets if there are no fives. if (!fives) { for (int e : a) { String numStr = String.valueOf(e); int num; if (numStr.length() > 2) { num = Integer.parseInt(numStr.substring(numStr.length() - 2)); } else { num = Integer.parseInt(numStr); } String nextNumStr = String.valueOf(num + num % 10); int nextNum; if (nextNumStr.length() > 2) { nextNum = Integer.parseInt(nextNumStr.substring(nextNumStr.length() - 2)); } else { nextNum = Integer.parseInt(nextNumStr); } if (evenSet.contains(num) || evenSet.contains(nextNum)) { if (odds) { result = "No"; break; } evens = true; } if (oddSet.contains(num) || oddSet.contains(nextNum)) { if (evens) { result = "No"; break; } odds = true; } } } System.out.println(result); } } 
 » 6 months ago, # |   0 In problem E, why flag12 and flag2 should not be true for the answer to be YES?
•  » » 6 months ago, # ^ |   0 Remainders 2, 4, 6, 8 cycles and in that cycle number increases by 20. So difference between every two elements must divide by 20 (and these elements must have the same remainder modulo 20).
•  » » » 6 months ago, # ^ |   0 If I understood it right, like if number 12 and 22 both exist in array we wont be able to make these numbers equal, since they will be be converted to 32 and 42 respectively, and this goes on, there wouldn't be a point where they will become equal.
 » 6 months ago, # |   0 i coded D iteratively, but its giving me MLE, can someone please tell me why ?iterative D soln
 » 6 months ago, # |   0 Why I got TLE ? What's wrong with my code[submission:166546367]
 » 6 months ago, # |   0 Is there a way to solve G using binary lifting
•  » » 6 months ago, # ^ |   0 Yes 167804403
 » 6 months ago, # |   0 Can someone kindly explain the solution for B?
•  » » 6 months ago, # ^ | ← Rev. 2 →   0 You can try to think the solution in this way: Either the integers occurs multiple times in array or just one time. If all are occurring single time, then problem is already solved and no changes required. If there are multiple occurrences, the rightmost occurrence of all the repeated elements can stay finally in answer array, and all elements till its 2nd occurrence from right has to be removed. So, we will have to find the second occurrence of each repeated element from the right. Finally, taking the maximum of all such indices observed in the previous step, will lead us to the answer.
 » 5 months ago, # |   0 Could someone explain why this submission for G of mine get TLE ? I know it's inefficient but I still don't get why it doesn't workFirst I do a dfs to precompute all prefix sums for a and b. Then for each leaf I find the path from it to the root, reverse the path, and use binary search for each vertices on the path to get the answer.
 » 5 months ago, # | ← Rev. 3 →   0 Hi can anyone help me figure out why my code for D is wrong? Thanks a lot! Basically I have tried to iteratively find the places with maximum coverage. However, it gives WA on a later TC. Code#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma") #pragma GCC optimize("unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef long double ld; typedef pair p32; typedef pair p64; typedef pair pdd; typedef vector v64; typedef vector v32; typedef vector > vv32; typedef vector > vv64; typedef vector > vvp64; typedef vector vp64; typedef vector vp32; double eps = 1e-12; #define forn(i,e) for(ll i = 0; i < e; i++) #define forsn(i,s,e) for(ll i = s; i < e; i++) #define rforn(i,s) for(ll i = s; i >= 0; i--) #define rforsn(i,s,e) for(ll i = s; i >= e; i--) #define ln "\n" #define dbg(x) cout<<#x<<" = "< void swp(T&a,T&b) { T temp=a; a=b; b=temp; } // Useful Funcs // smallest prime divisor // int smp[100001]={0}; // void calcPrimes(){ // forn(i,100001){ // smp[i]=i; // } // ll ct=2; // while(ct*ct<100001){ // if(smp[ct]==ct){ // for(ll j=ct*ct;j<100001;j+=ct){smp[j]=ct;}} // ct+=1; // } // } ll ceil_div(ll a, ll b) {return a % b == 0 ? a / b : a / b + 1;} // Recursive function to calculate gcd long long gcd(long long a, long long b){ if(b==0) return a; return gcd(b,a%b); } /* Iterative Function to calculate (x^y)%p in O(log y) */ long long modex(long long x, unsigned int y, long long p) { long long res = 1; // Initialize result x = x % p; // Update x if it is more than or // equal to p if (x == 0) return 0; // In case x is divisible by p; while (y > 0) { // If y is odd, multiply x with result if (y & 1) res = (res*x) % p; // y must be even now y = y>>1; // y = y/2 x = (x*x) % p; } return res; } int binarySearch(int arr[], int l, int r, int x) { if (r >= l) { int mid = l + (r - l) / 2; // If the element is present at the middle // itself if (arr[mid] == x) return mid; // If element is smaller than mid, then // it can only be present in left subarray if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); // Else the element can only be present // in right subarray return binarySearch(arr, mid + 1, r, x); } // We reach here when element is not // present in array return -1; } // STL binary search functions // binary_search(start_ptr, end_ptr, num) // returns true if element present, // otherwise returns false. // upper_bound(start_ptr, end_ptr, num) // returns the first index having value // greater than num. // If there is no such index, then returns // length of array. // lower_bound(start_ptr, end_ptr, num) // returns the fiirst index having value // not less than num // Subtract v.begin() or a(in case of array) to get index. // Pointers // for array-> a, a+x // for vector-> v.begin(), v.begin()+x, v.end() const ll MOD = 998244353; const ll mod = 1e9+7; void solve(){ string t; cin>>t; ll n; cin>>n; vector s(n); forn(i,n) cin>>s[i]; ll m = sz(t); v64 c(m); ll ans = 0; vp64 ansl; for(ll cv=10;cv>=1;--cv){ forn(i,m){ forn(j,n){ if(sz(s[j])>=cv && m-i>=sz(s[j])){ ll cov = 0; bool b=true; forn(k,sz(s[j])){ if(s[j][k]!=t[i+k]){ b=false; break; } else{ if(!c[i+k]) cov++; } } if(b && cov==cv){ ans++; ansl.pb({j+1,i+1}); forn(k,sz(s[j])){ c[i+k]=1; } } } } } } bool b=true; forn(i,sz(t)){ if(!c[i]){ b=false; break; } } if(b){ cout<> t; for(int it=1;it<=t;it++) { solve(); } return 0; } 
•  » » 5 months ago, # ^ |   0 Take a look at Ticket 16127 from CF Stress for a counter example.
•  » » » 5 months ago, # ^ |   0 Thanks! However, I am also interested to know why the editorial solution won't face the same problem as my solution.
•  » » » » 5 months ago, # ^ |   0 The testcase that I shared is pretty small, with only 3 candidate substrings. I would suggest you to dry run that testcase, first on your submission to find out why it doesn't work, and then on the editorialist's solution to figure out why their solution does not hit this issue.
 » 5 months ago, # |   0 Could someone tell me what's wrong with my solution for G here? I tried all the combos of lb/ub but test case 4 is WA each time.
•  » » 5 months ago, # ^ | ← Rev. 2 →   0 Use 'long long' type in sum variables. because sum of the numbers may not fit in integer.171566697
•  » » » 5 months ago, # ^ |   0 facepalm. Thanks!
 » 5 months ago, # |   0 For Problem D Solution: else Find(max(pos + 1, b +1), Max, t, str, match);I do not get why we are passing the max(pos + 1, b + 1) as the first argument , should it not be just pos + 1? Can anyone explain ?
 » 5 months ago, # | ← Rev. 2 →   0 I got wrong answer on test case 2 844th token but i couldnt realize why, I just modulo all the elements except 5 and 0 by 20 and tried to complete all to their max values < 20 by adding e= elements , while ( e + e%10 ) < 20 , {e += e%10} and also if e %10 == 5 round it up and compare the all elements in the array where am i wrong
•  » » 5 months ago, # ^ |   0 I fixed thanks.
 » 4 months ago, # |   0 In** E — Add modulo 10**, we can make an array of size 10 where a[i] is what needs to be added to numbers ending with i so that every number is ending with the same digit. This eliminates the inner while loop and makes the code slightly faster. My solution
 » 2 months ago, # |   0 Problem C in O(1) complexity (Python) 182612155
 » 7 weeks ago, # |   0 i have an easier code to understand about question B for new learners.186176378