Muhammad_Rahimov's blog

By Muhammad_Rahimov, history, 7 years ago, In English

Masala Tarjimasi:

Levko massivlar bilan o'ynashni yaxshi ko'rar ekan. Unda a1, a2, a3 ... an ko'rinishidagi massiv bor ekan. U massiv bilan o'ynash davomida, shu massiv ustida 2 xil amal bajarar ekan.

Bu amallar:
1. Birinchi turdagi amal bu: massivdagi indekslari L dan R gacha bo'lgan elementlarni D ga oshirish. ya'ni dasturlash tili bilan aytganda:

for(int i = L; i<=R; i++)
    a[i]+=D;
  1. Ikkinchi turdagi amal: massivdagi indekslari L dan R gacha bo'lgan elementlar ichidan maksimalini topish.
for(int i = L; i<=R; i++)
   mx = max(mx, a[i]);

Levko sevimli massivini yo'qotib qo'yibdi shuning uchun u sizdan yordam so'rayapdi. Unda faqat massiv ustida bajarilgan amallar ro'yhati bor holos. Levkoga massivni tiklashda yordam bering.

Kiruvchi ma'lumotlar:

Birinchi bo'lib bizga n va m ketma ket kiritiladi.

n -> massiv elementlari soni; 1<=n<=5000
m -> massiv ustida bajarilgan amallar soni; 1<=m<=5000

Keyingi m qatorda quyidagi tartibda ma'lumotlar kiritiladi:
1. t -> bajarilgan operatsiya tipi. Agar t = 1 bo'lsa u holda birinchi turdagi amal bajarilgan(qo'shish), agar t = 2 bo'lsa ikkinchi turdagi amal bajarilgan(maksimal topish). 1<=t<=2
2. l -> chap chegara 1<=l<=n
3. r -> o'ng chegara 1<=r<=n
4. d yoki m -> bajarilayotgan amal turiga qarap, agar birinchi turdagi amal bo'lsa qo'shilayotgan son, agar ikkinchi turdagi amal bo'lsa topilgan maksimal son.

Chiquvchi ma'lumotlar:

YES -> agar yechim bo'lsa
NO -> agar yechim bo'lmasa
Agar yechim bo'lsa YES yozuvi ostida massiv elementlari chiqarilsin. Massiv elementlari modul jihatda 1e9 dan oshmaydi. |ai|<=1e9

O'zlaringizda g'oya chiqarib ishlashga urinib ko'ringlar!!! Agar bo'lmasa quyidagi yechimda foydalaninglar.

Masala Yechimi:

yechimi
  • Vote: I like it
  • -3
  • Vote: I do not like it

»
7 years ago, # |
  Vote: I like it +11 Vote: I do not like it

Auto comment: topic has been updated by Muhammad_Rahimov (previous revision, new revision, compare).

»
7 years ago, # |
Rev. 2   Vote: I like it +9 Vote: I do not like it

Kodingni Block degan narsani ichiga tashasang bo'ladi. Link, Picturelarni qatorida 3-chi turibdi. Shunda kodni o'zi taniydi.

»
7 years ago, # |
  Vote: I like it +11 Vote: I do not like it

Auto comment: topic has been updated by Muhammad_Rahimov (previous revision, new revision, compare).

»
7 years ago, # |
  Vote: I like it +8 Vote: I do not like it

"Ammo almashtirish davomida shu massiv elementi boshlang'ich holatda qancha siljiganinigam hisobga olamiz:" shu qismni aniqroq tushuntirishni iloji bormi?

  • »
    »
    7 years ago, # ^ |
    Rev. 6   Vote: I like it +11 Vote: I do not like it
    topish kerak bolgan massivni a deb olsak 
    a[i] + diff[i] (1<=i<=n)
    massivning hozirgi(amallar bajarilgandan keyingi) holatini keltirib chiqaradi
    
»
7 years ago, # |
Rev. 2   Vote: I like it +3 Vote: I do not like it

Agar birinchi turdagi amal kelsa diff massivini yangilaymiz Yangilaymiz?? Nishatib? Agar ikkinchi turdagi element kelsa L — R oraliqda M kamida bir marta uchraydimi yo'qmi tekshiramiz Shu M 3 marta uchragan bo'lsa lekin bizardan asa shu bir xil M 4 marta so'ralsa nichik bo'ladi? Yoki vundin bo'lmasliqi aniqmi? Vuni ehtimolini go'rish shart amasmi?

  • »
    »
    7 years ago, # ^ |
      Vote: I like it +8 Vote: I do not like it

    Yangilaymiz dagani diff massivni l Dan r gacha d ga oshirib ketamiz. Kamida bir Marta uchrashi esa bizga shu maksimal l VA r oraliqda uchrashini tekshirish uchun kerak. Qancha Marta uchrashini ahamiyati yo'q. Masala shartida 4 yoki 5 VA hokazo Marta uchrasin degan shart yo'q