प्रौद्योगिकी साझेदारी

कोडफोर्स राउंड ९५७ (डिव. ३) २.

2024-07-12

한어Русский языкEnglishFrançaisIndonesianSanskrit日本語DeutschPortuguêsΕλληνικάespañolItalianoSuomalainenLatina

उ. केवलं प्लस्

 has three integers 𝑎, 𝑏 and 𝑐 ,has to give Noobish_Monk 𝑎×𝑏×𝑐 bananas.these integers and decided to do the following at most 5 times

एतेषु पूर्णाङ्केषु एकं चिनुत

तस्य वृद्धिः १

For example, if 𝑎=2, 𝑏=3 and 𝑐=4, then one can increase 𝑎 three times by one and increase 𝑏 two times. After that 𝑎=5, 𝑏=5, 𝑐=4. Then the total number of bananas will be 5×5×4=100.

the maximum value of 𝑎×𝑏×𝑐 

लोभी चिन्तनं, प्रत्येकं समये भवन्तः लघुतमं संख्यां +1 प्राप्नुवन्ति, तदा दत्तांशपरिधिः अतीव लघुः भवति, सा प्रत्यक्षतया हिंसकः भवति।

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define i64 long long
  4. void solve(){
  5. vector<int> a(3);
  6. for(int i = 0; i < 3; i ++) cin >> a[i];
  7. for(int i = 0; i < 5; i ++){
  8. sort(a.begin(), a.end());
  9. a[0] ++;
  10. }
  11. cout << (i64)a[0] * a[1] * a[2] << "n";
  12. }
  13. int main(){
  14. ios::sync_with_stdio(false);
  15. cin.tie(0);
  16. int T;
  17. cin >> T;
  18. while(T--)
  19. solve();
  20. return 0;
  21. }

ख. क्रुद्धः भिक्षुः

 k1o0n has baked an enormous 𝑛 metres long potato casserole. He has cut it into 𝑘 pieces, of lengths 𝑎1,𝑎2,…,𝑎𝑘 meters.k1o0n wasn't keen on that.

  • Pick a piece with length 𝑎𝑖≥2 and divide it into two pieces with lengths 1 and 𝑎𝑖−1. As a result, the number of pieces will increase by 1;
  • Pick a slice 𝑎𝑖 and another slice with length 𝑎𝑗=1 (𝑖≠𝑗) and merge them into one piece with length 𝑎𝑖+1. As a result, the number of pieces will decrease by 1.

For example, if 𝑛=5, 𝑘=2 and 𝑎=[3,2], it is optimal to do the following:

  • Divide the piece with length 2 into two pieces with lengths 2−1=1 and 1, as a result 𝑎=[3,1,1].
  • Merge the piece with length 3 and the piece with length 1, as a result 𝑎=[4,1].
  • Merge the piece with length 4 and the piece with length 1, as a result 𝑎=[5].

find the minimum number of operations he needs to do in order to merge the casserole into one piece with length 𝑛.(2≤𝑛≤10^9, 2≤𝑘≤10^5)

The second line contains 𝑘 integers 𝑎1,𝑎2,…,𝑎𝑘 (1≤𝑎𝑖≤𝑛−1, ∑𝑎𝑖=𝑛) 

लोभी चिन्तनशीलः, सर्वदा बृहत्तमसङ्ख्यायाः अतिरिक्ताः संख्याः विघटयन्तः

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define i64 long long
  4. void solve(){
  5. int n, k;
  6. cin >> n >> k;
  7. vector<int> a(k);
  8. for(int i = 0; i < k; i ++) cin >> a[i];
  9. sort(a.begin(), a.end());
  10. i64 res = 0;
  11. for(int i = 0; i < k - 1; i ++){
  12. if(a[i] == 1)
  13. res += 1;
  14. else{
  15. res += (a[i] + a[i] - 1);
  16. }
  17. }
  18. cout << res << endl;
  19. }
  20. int main(){
  21. ios::sync_with_stdio(false);
  22. cin.tie(0);
  23. int T;
  24. cin >> T;
  25. while(T--)
  26. solve();
  27. return 0;
  28. }

ग. गोरिल्ला तथा क्रमपरिवर्तन

 three numbers 𝑛, 𝑚, and 𝑘 (𝑚<𝑘).  construct a permutation† of length 𝑛,For the permutation, 𝑔(𝑖) is the sum of all the numbers in the permutation on a prefix of length 𝑖 that सन्ति not greater than 𝑚

𝑓(𝑖) is the sum of all the numbers in the permutation on a prefix of length 𝑖 that are not less than 𝑘.

find a permutation for which the value of (∑ni=1f(i)−∑ni=1g(i)) is maximized.(2≤𝑛≤10^5; 1≤m<k≤n)

f() बृहत्तमं कुरुत, अग्रे बृहत्, g() लघुतमं, लघु अग्रे कृत्वा

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define i64 long long
  4. void solve(){
  5. int n, k, m;
  6. cin >> n >> m >> k;
  7. for(int i = 0; i < n - m; i ++){
  8. cout << n - i << " ";
  9. }
  10. for(int i = 0; i < m; i ++)
  11. cout << i + 1 << " n"[i == m - 1];
  12. }
  13. int main(){
  14. ios::sync_with_stdio(false);
  15. cin.tie(0);
  16. int T;
  17. cin >> T;
  18. while(T--)
  19. solve();
  20. return 0;
  21. }

D. प्रेमस्य परीक्षा

अस्य प्रेमस्य परीक्षणं कर्तुं वयं निश्चयं कृतवन्तः। एर्न्कोर् इत्यनेन सह एकां नदीं तरितव्यं भविष्यति विस्तारः १ मीटर् तथाa length of 𝑛 meters.तस्मात् कुलेन (अर्थात् . throughout the entire swim from 0 to 𝑛+1) एर्न्कोर् जले तरितुं शक्नोति for no more than 𝑘 meters.

They are located at the 0 and 𝑛+1 meters respectively. The river can be represented as 𝑛 segments, each with a length of 1 meter. Each segmentलॉग 'L', ग्राहः 'C', केवलं जलं 'W' वा भवति । . ErnKor निम्नलिखितरूपेण गन्तुं शक्नोति ।

  • यदि सः उपरि (अर्थात् तटे वा लकडीयां वा), he can jump forward for no more than 𝑚 (1≤m≤101≤𝑚≤10) meters (he can jump on the bank, on a log, or in the water).
  • यदि सः जले अस्ति, . सः केवलं अग्रिमनदीखण्डं प्रति तरितुं शक्नोति (or to the bank if he is at the 𝑛-th meter).
  • एर्न्कोर् ग्राहेण सह खण्डे कथमपि अवतरितुं न शक्नोति।

p &lt; n अहं चिरकालात् अटन् अस्मि अहमपि लोभी अस्मि अहं समीपस्थं L प्राप्य गतिशीलरूपेण अद्यतनं कृतवान्।

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define i64 long long
  4. void solve(){
  5. int n, m, k;
  6. cin >> n >> m >> k;
  7. string tmp;
  8. cin >> tmp;
  9. string s = " " + tmp;
  10. int p = m;
  11. int i = 1;
  12. while(p <= n){
  13. for(int j = i; j <= p && p <= n; j ++){
  14. if(s[j] == 'L')
  15. p = j + m;
  16. }
  17. if(p > n)
  18. break;
  19. while(p <= n && s[p] == 'W' && k >= 0){
  20. k --;
  21. p ++;
  22. }
  23. if(k < 0 || ( p <= n && s[p] == 'C')){
  24. cout << "No" << endl;
  25. return;
  26. }else
  27. i = p;
  28. }
  29. cout << "Yes" << endl;
  30. }
  31. int main(){
  32. ios::sync_with_stdio(false);
  33. cin.tie(0);
  34. int T;
  35. cin >> T;
  36. while(T--)
  37. solve();
  38. return 0;
  39. }