Upgrade to Pro — share decks privately, control downloads, hide ads and more …

freeeのエンジニアが 就活で出そうな コーディングテストを 解説してみる

freeeのエンジニアが 就活で出そうな コーディングテストを 解説してみる

2024/05/09にfreee株式会社の本社で開催された、「freeeのエンジニアが就活で出そうなコーディングテストを解説してみる」の当日解説資料です。

▼イベントページ
https://freee.connpass.com/event/316572/

freee

May 15, 2024
Tweet

More Decks by freee

Other Decks in Programming

Transcript

  1. 4 ͸͡Ίʹ • ίʔσΟϯάࢼݧʹ΋͍͔ͭ͘छྨ͕͋Γ·͢ ◦ ΞϧΰϦζϜ໰୊ ▪ ໰୊Λղ͖ɺ༩͑ΒΕͨೖྗʹରͯ͠ɺ౴͑Λग़ྗ͢Δ໰୊ ▪ ࠓճ͸

    freee ͷίʔσΟϯάࢼݧͰ΋ग़୊͞Εͦ͏ͳʮΞϧΰϦζϜ໰୊ʯΛղઆ͍͖ͯ͠·͢ ◦ ෳࡶͳ࢓༷ʹରͯ͠ͷ࣮૷໰୊ ◦ SQL ΫΤϦ ◦ HTTP ϦΫΤετͷॲཧ ◦ ͳͲͳͲ
  2. 5 ໰୊1-1 จࣈྻ S ͕༩͑ΒΕ·͢ɻS ͔Β f Λ1ͭɺr Λ1ͭɺe Λ3ͭൈ͖ग़ͯ͠

    freee ͱ͍͏จࣈྻΛ࡞Γ·͢ɻ freee ͱ͍͏จࣈྻ͸࠷େԿݸ࡞Ε·͔͢ʁ ੍໿ 1 ≦ |S| ≦ 10^5 ( |S| ͸ S ͷจࣈྻͷ௕͞ͱ͢Δ ) ೖྗྫ serfefeereeo ग़ྗྫ 2
  3. 6 ໰୊1-1 ϙΠϯτ1. ࣮ࡍʹखΛಈ͔ͨ͠खॱΛ௥ͬͯΈΔ ᶃ f Λൈ͖ग़͢ɿʮserfefeereeoʯˠ ʮserefeereeoʯ ᶄ r

    Λൈ͖ग़͢ɿʮserefeereeoʯˠ ʮseefeereeoʯ ᶅ eee Λൈ͖ग़͢ɿʮseefeereeoʯˠ ʮsfereeoʯ ᶆ ᶃ ʙ ᶅͰൈ͖ग़ͨ͠จࣈͰ ʮfreeeʯ͕ 1ͭ ࡞ΕΔ ᶇ f Λൈ͖ग़͢ɿʮsfereeoʯˠ ʮsereeoʯ ᶈ r Λൈ͖ग़͢ɿʮsereeoʯˠ ʮseeeoʯ ᶉ eee Λൈ͖ग़͢ɿʮseeeoʯˠ ʮsoʯ ᶊ ᶇ ʙ ᶉͰൈ͖ग़ͨ͠จࣈͰ ʮfreeeʯ͕ 1ͭ ࡞ΕΔ ᶋ ͜ΕҎ্࡞Εͳ͍ͷͰɺ࡞ΕΔʮfreeeʯ͸ ߹ܭ 2 ͭ ্ͷૢ࡞Λ۪௚ʹϓϩάϥϜʹམͱ͠ࠐΉͷ͸ʮ΍΍େมʯ
  4. 7 ໰୊1-1 ϙΠϯτ2. ҧ͏ࢹ఺Ͱߟ͑Δ ʮfreeeʯͱ͍͏จࣈྻ͸ɺʮf ͕ 1ͭʯʮr ͕ 1ͭʯʮe ͕

    3ͭʯ͋Ε͹ 1 ͭ࡞ΕΔ → จࣈྻ͔Βʮf, r, eʯͷ਺͑͞෼͔Ε͹ɺʮfreeeʯͱ͍͏จࣈྻ͕࡞ΕΔݸ਺͸ٻΊΒΕΔ ྫ1. ʮserfefeereeoʯ: f ͕ 2ͭɺr ͕ 2ͭɺe ͕ 6ͭ • f Λ 2 ͭɺr Λ 2 ͭɺe Λ 6ͭ࢖ͬͯɺfreee ͸ 2ͭ࡞ΕΔ ྫ2. ʮerfxeefefroʯ: f ͕ 3ͭɺr ͕ 2ͭɺe ͕ 4ͭ • f Λ 1 ͭɺr Λ 1 ͭɺe Λ 3ͭ࢖ͬͯɺfreee ͸ 1ͭ࡞ΕΔ • f ͕ 2 ͭɺr ͕ 1 ͭɺe ͕ 1ͭ༨Δ͕ɺe ͷ਺͕଍Γͳ͍ͷͰ͜ΕҎ্࡞Εͳ͍ ݁Ռɿʮf ͷ਺ʯʮr ͷ਺ʯʮe/3(੾Γࣺͯ) ͷ਺ʯͷ࠷খ஋͕ʮfreeeʯΛ࡞ΕΔ਺ʹͳΔ
  5. 8 ໰୊1-1 ٙࣅίʔυྫ (ೖྗ͸ল͖·͢) f_count = 0 r_count = 0

    e_count = 0 for: i = 1 ~ |S| if: S[i]=”f“ ͳΒ f_count += 1 else if: S[i] = ”r“ ͳΒ r_count += 1 else if: S[i] = ”e” ͳΒ e_count += 1 freee_cnt = min(f_count, r_count, e_count / 3)
  6. 9 ໰୊1-2 จࣈྻ S ͕༩͑ΒΕ·͢ɻS ͔Β f Λ1ͭɺr Λ1ͭɺe Λ3ͭൈ͖ग़ͯ͠ݩͷॱ൪Λอͬͨ··

    freee ͱ͍ ͏จࣈྻΛ࡞Γ·͢ɻfreee ͱ͍͏จࣈྻ͸࠷େԿݸ࡞Ε·͔͢ʁ ੍໿ 1 ≦ |S| ≦ 10^5 ( |S| ͸ S ͷจࣈྻͷ௕͞ͱ͢Δ ) ೖྗྫ frefseereoeeeeerf ग़ྗྫ 2
  7. 10 ໰୊1-2 ϙΠϯτ1. ࣮ࡍʹखΛಈ͔ͨ͠खॱΛ௥ͬͯΈΔ ᶃ f Λൈ͖ग़͢ɿʮfrefseereoeeeeerfʯ ᶄ f ΑΓޙΖʹ͋Δ

    r Λൈ͖ग़͢ɿʮfrefseereoeeeeerfʯ ᶅ r ΑΓޙΖʹ͋Δ eee Λൈ͖ग़͢ɿʮfrefseereoeeeeerfʯ ᶆ ᶃ ʙ ᶅͰൈ͖ग़ͨ͠จࣈͰ ʮfreeeʯ͕1ͭ ࡞ΕΔɿʮfrefseereoeeeeerfʯˠʮfsreoeeeeerfʯ ᶇ f Λൈ͖ग़͢ɿʮfsreoeeeeerfʯ ᶈ f ΑΓޙΖʹ͋Δ r Λൈ͖ग़͢ɿʮfsreoeeeeerfʯ ᶉ r ΑΓޙΖʹ͋Δ eee Λൈ͖ग़͢ɿʮfsreoeeeeerfʯ ᶊ ᶇ ʙ ᶉͰൈ͖ग़ͨ͠จࣈͰ ʮfreeeʯ͕1ͭ ࡞ΕΔɿʮfsreoeeeeerfʯˠʮsoeeerfʯ ᶋ f Λൈ͖ग़͢ɿʮsoeeerfʯ ➓ f ΑΓޙΖʹ͋Δ r Λൈ͖ग़͢ɿͳ͍ͷͰऴྃɻ݁Ռ͸ 2ͭ
  8. 11 ໰୊1-2 ※ จࣈΛऔΓग़͢Ґஔʹ஫ҙ • f Λൈ͖ग़͢ɿʮfrefeereeʯ • f ΑΓޙΖʹ͋Δ

    r Λൈ͖ग़͢ɿʮfrefeereeʯ ◦ r Λൈ͖ग़ͤΔҐஔ͸2ͭ͋Δ͕ɺΑΓࠨʹ͋ΔҐஔ͔Β r ΛऔΓग़͢ͷ͕࠷ద ͳͥɺΑΓࠨʹ͋ΔҐஔ͕͍͍ͷ͔ • ʮf r e f e e r e e eʯͷ f ʹରͯ͠औΕΔ r ͸ 2 ͭ ◦ ࠨଆʹ͋Δ r Λͱͬͨ࣌ɿ ▪ ʮfrefeereeeʯˠʮfrefeereeeʯˠʮfrefeereeeʯ ▪ ʮfreeeʯɿ 2ͭ࡞ΕΔ ◦ ӈଆʹ͋Δ r Λͱͬͨ࣌ɿ ▪ ʮfrefeereeeʯˠʮfrefeereeeʯˠʮfrefeereeeʯ ▪ ʮrefeeʯɿ1͔ͭ͠࡞Εͳ͍
  9. 12 ໰୊1-2 ※ จࣈΛऔΓग़͢Ґஔʹ஫ҙ ͳͥɺΑΓࠨʹ͋ΔҐஔ͕͍͍ͷ͔ • ͦΕͧΕͷ f ͕औΕΔ r

    ͷൣғΛߟ͑Δ ◦ 1จࣈ໨ͷ fɿʮf r e f e e r e e eʯɿऔΕΔ r ͸ 2ͭ ◦ 2จࣈ໨ͷ fɿʮf r e f e e r e e eʯɿऔΕΔ r ͸ 1ͭ • f ͕ӈଆʹ͋Ε͹͋Δ΄Ͳɺr ͷऔΕΔൣғ͸ڱ͘ͳΔ (औΕΔൣғ͸ f ΑΓޙΖͷจࣈͳͷͰ) • औΕΔ r ͷൣғ಺ͷࠨଆͰ͋Δ΄Ͳɺ࣍ͷ f ͕औΕΔൣғ಺ͷจࣈΛ৵৯͠ͳ͍ • r ͷޙʹൈ͖ग़͢ e ʹ͍ͭͯ΋ಉ༷ • ࠨ͔Βॱ൪ʹจࣈྻΛૢ࡞͍ͯ͘͠ͱ͍͍
  10. 13 ໰୊1-2 ૢ࡞Λίʔυʹམͱ͠ࠐΜͰΈΔ ೖྗྫɿʮfrreefeereeeʯ • ඞཁͳม਺ɾૢ࡞ ◦ freee_count: freee ͕࡞ΕΔݸ਺

    ◦ f_count: ݱ࣌఺Ͱͷ f ͷ਺Λ਺͑Δ ◦ fr_count: f ͱ r Λ ൈ͖ग़͠ɺݱ࣌఺Ͱ࡞ΕΔ fr ͷ਺Λ਺͑Δ ▪ ͜ͷ࣌ f Λൈ͖ग़͢ͷͰɺf_count Λ -1 ͠ɺfr_count Λ +1 ͢Δ ▪ f_count = 0 ͷ৔߹͸ɺfr Λ࡞Εͳ͍ͷͰԿ΋͠ͳ͍ ◦ e_count: fr ͱ݁ͼ͚ͭΔ e ͷ਺Λ਺͑Δ ▪ fr_count = 0 ͷ৔߹͸ɺfr ʹ݁ͼ͚ͭΔ e ͸ͳ͍ͷͰԿ΋͠ͳ͍ ▪ e_count = 3 ʹͳͬͨͱ͖ɺfr ͱ eee Λൈ͖ग़ͯ͠ freee Λ࡞Δ • fr_count Λ -1ɺe_count Λ -3 ͯ͠ɺfreee_count Λ +1 ͢Δ
  11. 14 ໰୊1-2 ૢ࡞Λίʔυʹམͱ͠ࠐΜͰΈΔ ೖྗྫɿʮfrreefeereeeʯ • 1จࣈ໨( f )ɿʮfrreefeereeeʯ ◦ freee

    Λ࡞ΔͨΊʹ͸ ʮ f ʯ͕ඞਢͳͷͰɺຖճൈ͖ग़͢ ◦ ൈ͖ग़ͨ͠ f ͷ਺Λอ͓࣋ͯ͘͠ɿf_count += 1 • 2จࣈ໨( r )ɿʮfrreefeereeeʯ, f_count ͸ 1 ◦ r Λൈ͖ग़͢ʹ͸ɺ͜Ε·Ͱͷૢ࡞Ͱ f Λൈ͖ग़͍ͯ͠Δඞཁ͕͋Δ ▪ f Λൈ͖ग़ͤΔ: f_count > 0 ͳΒ • r Λൈ͖ग़ͯ͠ɺfr ͱ͍͏จࣈΛ࡞Δɿfr_count += 1 • f ͱ r Λ࢖ͬͯ fr Λ࡞ͬͨͨΊɺf ͷΧ΢ϯτΛ 1 ݮΒ͢ɿf_count -= 1 • 3จࣈ໨(r)ɿʮfrreefeereeeʯ, f_count ͸ 0, fr_count ͸ 1 ◦ ݁ͼ͚ͭΔ f ͕ͳ͍ͷͰɺfr ͸࡞Εͳ͍ɻΑͬͯ skip
  12. 15 ໰୊1-2 ૢ࡞Λίʔυʹམͱ͠ࠐΜͰΈΔ • 4จࣈ໨(e)ɿʮfrreefeereeeʯ, f_count ͸ 0, fr_count ͸

    1 ◦ e Λൈ͖ग़͢ʹ͸ɺ͜Ε·Ͱͷૢ࡞Ͱ fr Λൈ͖ग़͍ͯ͠Δඞཁ͕͋Δ ▪ fr_count > 0 ͳΒ • e Λൈ͖ग़͢ɿe_count += 1 • 5จࣈ໨(e)ɿʮfrreefeereeeʯ, f_count ͸ 0, fr_count ͸ 1, e_count ͸ 1 ◦ e Λൈ͖ग़͢ʹ͸ɺ͜Ε·Ͱͷૢ࡞Ͱ fr Λൈ͖ग़͍ͯ͠Δඞཁ͕͋Δ ▪ fr_count > 0 ͳΒ • e Λൈ͖ग़͢ɿe_count += 1 • 6จࣈ໨( f )ɿʮfrreefeereeeʯ, f_count ͸ 0, fr_count ͸ 1, e_count ͸ 2 ◦ freee Λ࡞ΔͨΊʹ͸ ʮ f ʯ͕ඞਢͳͷͰɺຖճൈ͖ग़͢ɿf_count += 1
  13. 16 ໰୊1-2 ૢ࡞Λίʔυʹམͱ͠ࠐΜͰΈΔ • 7จࣈ໨(e)ɿʮfrreefeereeeʯ, f_count ͸ 1, fr_count ͸

    1, e_count ͸ 2 ◦ e Λൈ͖ग़͢ʹ͸ɺ͜Ε·Ͱͷૢ࡞Ͱ fr Λൈ͖ग़͍ͯ͠Δඞཁ͕͋Δ ▪ fr_count > 0 ͳΒ • e Λൈ͖ग़͢ɿe_count += 1 ◦ e_count ͷ਺͕ 3 ʹͳͬͨͷͰɺfreee ͱ͍͏จࣈ͕ 1ͭ࡞Εͨʮfrreefeereeeʯ ▪ fr 1ͭͱ e 3ͭΛ࢖͏ͷͰɿfreee_count += 1, fr_count -= 1, e_count -= 3 • 8จࣈ໨(e)ɿʮfrreefeereeeʯ, f_count ͸ 1, fr_count ͸ 0, e_count ͸ 0, freee_count ͸ 1 ◦ e Λൈ͖ग़͢ʹ͸ɺ͜Ε·Ͱͷૢ࡞Ͱ fr Λൈ͖ग़͍ͯ͠Δඞཁ͕͋Δ ▪ fr_count = 0 ͳͷͰ skip
  14. 17 ໰୊1-2 ૢ࡞Λίʔυʹམͱ͠ࠐΜͰΈΔ • 9จࣈ໨(r)ɿʮfrreefeereeeʯ, f_count ͸ 1, fr_count ͸

    0, e_count ͸ 0, freee_count ͸ 1 ◦ r Λൈ͖ग़͢ʹ͸ɺ͜Ε·Ͱͷૢ࡞Ͱ f Λൈ͖ग़͍ͯ͠Δඞཁ͕͋Δ ▪ f_count > 0 ͳΒ fr Λ࡞Δ • f_count -= 1, fr_count += 1 • 10จࣈ໨(e)ɿʮfrreefeereeeʯ, f_count ͸ 0, fr_count ͸ 1, e_count ͸ 0, freee_count ͸ 1 ◦ eΛൈ͖ग़͢ʹ͸ɺ͜Ε·Ͱͷૢ࡞Ͱ fr Λൈ͖ग़͍ͯ͠Δඞཁ͕͋Δ ▪ fr_count > 0 ͳΒ • e Λൈ͖ग़͢ɿe_count += 1 • 11จࣈ໨(e)ɿʮfrreefeereeeʯ, f_count ͸ 0, fr_count ͸ 1, e_count ͸ 1, freee_count ͸ 1 ◦ fr_count > 0 ͳΒ ▪ e Λൈ͖ग़͢ɿe_count += 1
  15. 18 ໰୊1-2 ૢ࡞Λίʔυʹམͱ͠ࠐΜͰΈΔ • 12จࣈ໨(e)ɿʮfrreefeereeeʯ, f_count ͸ 0, fr_count ͸

    1, e_count ͸ 2, freee_count ͸ 1 ◦ fr_count > 0 ͳΒ ▪ e Λൈ͖ग़͢ɿe_count += 1 ◦ e_count ͷ਺͕ 3 ʹͳͬͨͷͰɺfreee ͱ͍͏จࣈ͕ 1ͭ࡞Εͨʮfrreefeereeeʯ ▪ fr 1ͭͱ e 3ͭΛ࢖͏ͷͰɿfreee_count += 1, fr_count -= 1, e_count -= 3 • จࣈྻͷૢ࡞ऴྃ ◦ f_count = 0, fr_count = 0, e_count = 0, freee_count = 2 ◦ ݁Ռͱͯ͠ɺ࡞ΕΔ freee ͷ਺͸ freee_count = 2 ͭ
  16. 19 ໰୊1-2 ٙࣅίʔυྫ (ೖྗ͸ল͖·͢) f_count = 0, fr_count = 0,

    e_count = 0, freee_count = 0 for: i = 1 ~ |S| if: S[i] == “f” ͳΒ f_count += 1 else if: S[i] == “r” ͔ͭ f_count > 0 ͳΒ fr_count += 1 f_count -= 1 else if: S[i] == “e” ͔ͭ fr_count > 0 ͳΒ e_count += 1 if: e_count == 3 ͳΒ e_count -= 3 fr_count -= 1 freee_count += 1 freee_count Λग़ྗ͢Δ
  17. 20 ໰୊2-1 ੍໿ 0 ≦ N ≦ 2×10^9 2 ≦

    M ≦ 5×10^3 0 ≦ A_i ≦ 10^9 ೖྗྫ ༑ୡͱΫϦεϚεϓϨθϯτͷަ׵ձΛߦ͍·͢ɻ ϓϨθϯτ͸1ਓ2ͭબͿࣄʹͳ͓ͬͯΓɺ߹ܭͷֹۚ͸ N ԁҎԼʹऩΊͳ͍ͱ͍͚·ͤΜɻ ީิͱͯ͠ M ݸͷϓϨθϯτ͕͋Γɺi൪໨ͷϓϨθϯτͷ஋ஈ͸ A_i ԁͰ͢ɻ ॏෳ͠ͳ͍Α͏ʹϓϨθϯτΛ 2ͭબΜͩ࣌ɺ༧ࢉ N ԁҎԼͱͳΔ૊Έ߹Θͤ͸͍ͭ͋͘Γ·͔͢ʁ 500 5 100 200 300 400 500 ग़ྗྫ 4
  18. 21 ໰୊2-1 ϙΠϯτ1. ࣮ࡍʹखΛಈ͔ͨ͠खॱΛ௥ͬͯΈΔ ᶃ ϓϨθϯτ1 ͱ ϓϨθϯτ2ɿ(100 200 300

    400 500)ɿ߹ܭ300ԁ ᶄ ϓϨθϯτ1 ͱ ϓϨθϯτ3ɿ(100 200 300 400 500)ɿ߹ܭ400ԁ ᶅ ϓϨθϯτ1 ͱ ϓϨθϯτ4ɿ(100 200 300 400 500)ɿ߹ܭ500ԁ ᶆ ϓϨθϯτ1 ͱ ϓϨθϯτ5ɿ(100 200 300 400 500)ɿ߹ܭ600ԁ ᶇ ϓϨθϯτ2 ͱ ϓϨθϯτ3ɿ(100 200 300 400 500)ɿ߹ܭ500ԁ ᶈ ϓϨθϯτ2 ͱ ϓϨθϯτ4ɿ(100 200 300 400 500)ɿ߹ܭ600ԁ ᶉ ϓϨθϯτ2 ͱ ϓϨθϯτ5ɿ(100 200 300 400 500)ɿ߹ܭ700ԁ ᶊ ϓϨθϯτ3 ͱ ϓϨθϯτ4ɿ(100 200 300 400 500)ɿ߹ܭ700ԁ ᶋ ϓϨθϯτ3 ͱ ϓϨθϯτ5ɿ(100 200 300 400 500)ɿ߹ܭ800ԁ ➓ ϓϨθϯτ4 ͱ ϓϨθϯτ5ɿ(100 200 300 400 500)ɿ߹ܭ900ԁ 500ԁҎԼͱͳΔͷ͸ ᶃɾᶄɾᶅɾᶇ ͳͷͰɺ౴͑͸ 4
  19. 22 ໰୊2-1 ϙΠϯτ1. ࣮ࡍʹखΛಈ͔ͨ͠खॱΛ௥ͬͯΈΔ • ͦΕͧΕͷ૊Έ߹ΘͤΛશ୳ࡧ͢Ε͹ྑ͍ʂ • (i, j) Λʮi൪໨ͷϓϨθϯτʯͱʮj൪໨ͷϓϨθϯτʯͷ૊ͱදݱͨ࣌͠

    ◦ શͯͷ૊͸ɿ(1, 2)(1, 3)(1, 4)(1, 5)(2, 3)(2, 4)(2, 5)(3, 4)(3, 5)(4, 5) ͰදͤΔ • ͜ͷ(i, j)ͷ஋Λ ϧʔϓͯ͠୳ࡧ͍ͯ͘͠ ◦ i = 1 ͷ࣌ɺj = 2, 3, 4, 5 ◦ i = 2 ͷ࣌ɺj = 3, 4, 5 ◦ i = 3 ͷ࣌ɺj = 4, 5 ◦ i = 4 ͷ࣌ɺj = 5 • ҰൠԽ͢Δͱ ◦ i = 1 ~ M - 1 ·Ͱ ϧʔϓ͢Δ ▪ j = i + 1 ~ M ·Ͱ ϧʔϓ͢Δ • (i, j) ͱ (j, i) ͷΑ͏ʹ ಉ͡૊Λ਺͑ͳ͍ͨΊʹ i < j ʹ͍ͯ͠·͢
  20. 23 ໰୊2-1 ٙࣅίʔυྫ (ೖྗ͸ল͖·͢) answer = 0 for: i =

    1 ~ M - 1 for: j = i + 1 ~ M if (A[i] + A[j] <= N) answer += 1 answer Λग़ྗ
  21. 24 ໰୊2-2 ༑ୡͱΫϦεϚεϓϨθϯτͷަ׵ձΛߦ͍·͢ɻ ϓϨθϯτ͸1ਓ2ͭબͿࣄʹͳ͓ͬͯΓɺ߹ܭͷֹۚ͸ N ԁҎԼʹऩΊͳ͍ͱ͍͚·ͤΜɻ ީิͱͯ͠ M ݸͷϓϨθϯτ͕͋Γɺi൪໨ͷϓϨθϯτͷ஋ஈ͸ A_i

    ԁͰ͢ɻ ॏෳ͠ͳ͍Α͏ʹϓϨθϯτΛ 2ͭબΜͩ࣌ɺ༧ࢉ N ԁҎԼͱͳΔ૊Έ߹Θͤ͸͍ͭ͋͘Γ·͔͢ʁ ੍໿(໰୊2-1 ͱൺֱͯ͠ɺϓϨθϯτͷީิ਺ M ͕େ͖͘ͳͬͨ) 0 ≦ N ≦ 2×10^9 2 ≦ M ≦ 2×10^5 0 ≦ A_i ≦ 10^9 ೖྗྫ 500 5 100 200 300 400 500 ग़ྗྫ 4
  22. 25 ໰୊2-2 ໰୊2-1 ͷղ๏ ͷ୳ࡧεςοϓ਺ • M = 5 ͷ࣌ɺ(i,

    j) ͷ୳ࡧͷ࢓ํΛݟ͍ͯ͘ ◦ i = 1 ͷ࣌ɺj = 2, 3, 4, 5ɿ4 εςοϓ ◦ i = 2 ͷ࣌ɺj = 3, 4, 5ɿ3 εςοϓ ◦ i = 3 ͷ࣌ɺj = 4, 5ɿ2 εςοϓ ◦ i = 4 ͷ࣌ɺj = 5ɿ1 εςοϓ • ߹ܭ 10 εςοϓ • M = m ͷ࣌ɿm(m - 1) / 2 εςοϓ • ໰୊2-2 ͷ M ͷ࠷େ஋͸ 2×10^5 ◦ ໰୊2-1 ͷղ๏ͩͱ ໿ 2×10^10 εςοϓ ͔͔ͬͯ͠·͏ͨΊɺղ๏Λ޻෉͠ͳ͍ͱ͍͚ͳ͍ɻ ◦ (࣮ߦ͢Δಈ࡞؀ڥʹΑΔ͕)਺ेඵʙ਺෼͔͔Δ ▪ ޻෉͢Δͱ ໿ 1ඵҎ಺ʹͰ͖Δ
  23. 26 ໰୊2-2 ϙΠϯτ1. i ൪໨ͷϓϨθϯτͱ૊Έ߹Θ͕ͤՄೳͳൣғΛ௥ͬͯΈΔ ᶃ ϓϨθϯτ1 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200

    300 450 450)ɿ2 ~ 6൪໨ ᶄ ϓϨθϯτ2 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿ3 ~ 4൪໨ ᶅ ϓϨθϯτ3 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿ4൪໨ ᶆ ϓϨθϯτ4 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿͳ͠ ᶇ ϓϨθϯτ5 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿͳ͠ ᶈ ϓϨθϯτ6 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿͳ͠ ্Λ؍࡯͢Δͱɺi Λ ਐΊΔʹͭΕͯɺऔΕΔൣғ͕ڱ·͍ͬͯ͘͜ͱ͕෼͔Δ ೖྗྫ 500 6 50 100 200 300 450 450
  24. 27 ໰୊2-2 ϙΠϯτ1. i ൪໨ͷϓϨθϯτͱ૊Έ߹Θ͕ͤՄೳͳൣғΛ௥ͬͯΈΔ ᶃ ϓϨθϯτ1 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200

    300 450 450)ɿ2 ~ 6൪໨ ᶄ ϓϨθϯτ2 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿ3 ~ 4൪໨ ᶅ ϓϨθϯτ3 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿ4൪໨ ্Λ؍࡯͢Δͱɺi Λ ਐΊΔʹͭΕͯɺऔΕΔൣғ͕ڱ·͍ͬͯ͘͜ͱ͕෼͔Δ • ͨͩ͠ɺϓϨθϯτͷ஋ஈ͕ ঢॱ ʹฒΜͰ͍Δ͜ͱ͕લఏ ◦ ϓϨθϯτ1(A[1] = 50) ͱ૊ʹͳΕΔͷ͸ 450 ԁҎԼͷϓϨθϯτ ◦ 450 ԁҎԼͱͳΔϓϨθϯτͷ࠷ӈͷҐஔ j ͕෼͔Ε͹ɺϓϨθϯτ1 ͔Β ϓϨθϯτ j ͷ ൣғ͸ɺϓϨθϯτ1ͱઈର ʹ૊Λ࡞ΕΔ ▪ ʢঢॱʹͳ͍ͬͯΔ͜ͱʹΑΓʣϓϨθϯτ j ΑΓࠨ͸ඞͣ 450 ԁΑΓখ͍ͨ͞Ί ೖྗྫ 500 6 50 100 200 300 450 450
  25. 28 ໰୊2-2 ϙΠϯτ1. i ൪໨ͷϓϨθϯτͱ૊Έ߹Θ͕ͤՄೳͳൣғΛ௥ͬͯΈΔ i ൪໨ͷϓϨθϯτ͕औΕΔൣғͷӈ୺Λ r ͱ͢Δɻ ᶃ

    ϓϨθϯτ1 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 1, r = 6ɿऔΕΔϓϨθϯτ(r - i = 5) ᶄ ϓϨθϯτ2 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 2, r = 4ɿऔΕΔϓϨθϯτ(r - i = 2) ᶅ ϓϨθϯτ3 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 3, r = 4ɿऔΕΔϓϨθϯτ(r - i = 1) ᶆ ϓϨθϯτ4 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 4, r = 3 ᶇ ϓϨθϯτ5 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 5, r = 2 ᶈ ϓϨθϯτ6 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 6, r = 1 i ͷҐஔ͕ӈʹਐΉʹͭΕͯɺr ͷ Ґஔ͕ࠨʹਐΜͰ͍͘͜ͱ͕෼͔ΔʢঢॱʹฒΜͰ͍Δ͜ͱ͕৚݅ʣ
  26. 29 ໰୊2-2 ϙΠϯτ1. i ൪໨ͷϓϨθϯτͱ૊Έ߹Θ͕ͤՄೳͳൣғΛ௥ͬͯΈΔ i ൪໨ͷϓϨθϯτ͕औΕΔൣғͷӈ୺Λ r ͱ͢Δɻ ᶃ

    ϓϨθϯτ1 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 1, r = 6ɿऔΕΔϓϨθϯτ(r - i = 5) ᶄ ϓϨθϯτ2 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 2, r = 4ɿऔΕΔϓϨθϯτ(r - i = 2) ᶅ ϓϨθϯτ3 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 3, r = 4ɿऔΕΔϓϨθϯτ(r - i = 1) i ͷҐஔ͕ӈʹਐΉʹͭΕͯɺr ͷ Ґஔ͕ࠨʹਐΜͰ͍͘͜ͱ͕෼͔ΔʢঢॱʹฒΜͰ͍Δ͜ͱ͕৚݅ʣ • ᶃɿi = 1ͷ࣌ (A[i] = 50) ◦ r = 6 (A[r] = 450) ͷ࣌఺Ͱ A[i] + A[r] = 500 ͱͳΓɺ500ԁҎԼΛຬͨ͢ ◦ औΕΔൣғΛ஌ΔͨΊʹɺ͜ΕҎ্ r Λ ࠨʹਐΊΔඞཁ͸ͳ͍ ▪ ͳͥͳΒɺʮi ൪໨ͷϓϨθϯτ͕औΕΔൣғͷӈ୺Λ r ʯͱ͍ͯ͠Δ͔Β ◦ r ΑΓࠨʹ͋Δ஋͸ɺA[r] ΑΓখ͍͞͸ͣͳͷͰɺϓϨθϯτ i ͱ૊Λඞͣ࡞ΕΔ ▪ ݁Ռͱͯ͠ɺϓϨθϯτ1 ͱऔΕΔ૊͸ (r - i = 5 ݸ)Ͱ͋Δ͜ͱ͕ٻΊΒΕΔ
  27. 30 ໰୊2-2 ϙΠϯτ1. i ൪໨ͷϓϨθϯτͱ૊Έ߹Θ͕ͤՄೳͳൣғΛ௥ͬͯΈΔ i ൪໨ͷϓϨθϯτ͕औΕΔൣғͷӈ୺Λ r ͱ͢Δɻ ᶃ

    ϓϨθϯτ1 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 1, r = 6ɿऔΕΔϓϨθϯτ(r - i = 5) ᶄ ϓϨθϯτ2 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 2, r = 4ɿऔΕΔϓϨθϯτ(r - i = 2) ᶅ ϓϨθϯτ3 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 3, r = 4ɿऔΕΔϓϨθϯτ(r - i = 1) i ͷҐஔ͕ӈʹਐΉʹͭΕͯɺr ͷ Ґஔ͕ࠨʹਐΜͰ͍͘͜ͱ͕෼͔ΔʢঢॱʹฒΜͰ͍Δ͜ͱ͕৚݅ʣ • ᶄɿi = 2ͷ࣌ (A[i] = 100) ◦ r = 6 (A[r] = 450) ͷ࣌ɺA[i] + A[r] = 550 ͱͳΓɺ৚݅Λຬͨ͞ͳ͍ ◦ r = 5 (A[r] = 450) ͷ࣌ɺA[i] + A[r] = 550 ͱͳΓɺ৚݅Λຬͨ͞ͳ͍ ◦ r = 4 (A[r] = 300) ͷ࣌ɺA[i] + A[r] = 400 ͱͳΓɺ500ԁҎԼΛຬͨ͢ ◦ औΕΔൣғΛ஌ΔͨΊʹɺ͜ΕҎ্ r Λ ࠨʹਐΊΔඞཁ͸ͳ͍ ▪ ݁Ռͱͯ͠ɺϓϨθϯτ2 ͱऔΕΔ૊͸ (r - i = 2 ݸ)Ͱ͋Δ͜ͱ͕ٻΊΒΕΔ
  28. 31 ໰୊2-2 ϙΠϯτ1. i ൪໨ͷϓϨθϯτͱ૊Έ߹Θ͕ͤՄೳͳൣғΛ௥ͬͯΈΔ i ൪໨ͷϓϨθϯτ͕औΕΔൣғͷӈ୺Λ r ͱ͢Δɻ ᶃ

    ϓϨθϯτ1 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 1, r = 6ɿऔΕΔϓϨθϯτ(r - i = 5) ᶄ ϓϨθϯτ2 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 2, r = 4ɿऔΕΔϓϨθϯτ(r - i = 2) ᶅ ϓϨθϯτ3 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 3, r = 4ɿऔΕΔϓϨθϯτ(r - i = 1) i ͷҐஔ͕ӈʹਐΉʹͭΕͯɺr ͷ Ґஔ͕ࠨʹਐΜͰ͍͘͜ͱ͕෼͔ΔʢঢॱʹฒΜͰ͍Δ͜ͱ͕৚݅ʣ • ᶅɿi = 3ͷ࣌ (A[i] = 200) ◦ લճ(i = 2ɿA[i] = 100 ͷ࣌) r = 4 ·ͰݟͨͷͰɺr = 4 ͔Β࢝ΊΔ ▪ i ͕ӈʹਐΉͱɺA[i] ͷ஋͸্ঢ͢ΔɻͦͷͨΊɺr ͷ஋͸ݮΒ͢ํ޲ʹಈ͔͔͢͠ͳ͍(ࠨͷํ޲) ◦ r = 4 (A[r] = 300) ͷ࣌ɺA[i] + A[r] = 500 ͱͳΓɺ500ԁҎԼΛຬͨ͢ ◦ औΕΔൣғΛ஌ΔͨΊʹɺ͜ΕҎ্ r Λ ࠨʹਐΊΔඞཁ͸ͳ͍ ▪ ݁Ռͱͯ͠ɺϓϨθϯτ3 ͱऔΕΔ૊͸ (r - i = 1 ݸ)Ͱ͋Δ͜ͱ͕ٻΊΒΕΔ
  29. 32 ໰୊2-2 ϙΠϯτ1. i ൪໨ͷϓϨθϯτͱ૊Έ߹Θ͕ͤՄೳͳൣғΛ௥ͬͯΈΔ i ൪໨ͷϓϨθϯτ͕औΕΔൣғͷӈ୺Λ r ͱ͢Δɻ ᶃ

    ϓϨθϯτ1 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 1, r = 6ɿऔΕΔϓϨθϯτ(r - i = 5) ᶄ ϓϨθϯτ2 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 2, r = 4ɿऔΕΔϓϨθϯτ(r - i = 2) ᶅ ϓϨθϯτ3 ͱ૊Λ࡞ΕΔൣғɿ(50 100 200 300 450 450)ɿi = 3, r = 4ɿऔΕΔϓϨθϯτ(r - i = 1) i ͷҐஔ͕ӈʹਐΉʹͭΕͯɺr ͷ Ґஔ͕ࠨʹਐΜͰ͍͘͜ͱ͕෼͔ΔʢঢॱʹฒΜͰ͍Δ͜ͱ͕৚݅ʣ • ᶆɿi = 4ͷ࣌ (A[i] = 300) ◦ લճ(i = 3ɿA[i] = 200 ͷ࣌) r = 4 ·ͰݟͨͷͰɺr = 4 ͔Β࢝ΊΔ ◦ r = 4 (A[r] = 300) ͷ࣌ɺA[i] + A[r] = 600 ͱͳΓɺ৚݅Λຬͨ͞ͳ͍ ◦ r = 3 (A[r] = 200) ͷ࣌ɺA[i] + A[r] = 500 ͱͳΓɺ500ԁҎԼΛຬͨ͢ ▪ ͔͠͠ i = 4, r = 3 ͷ৚݅͸ɺi = 3, r = 4 ͷ࣌ʹΧ΢ϯτ͍ͯ͠ΔͨΊແࢹ͢Δ ▪ ͳͷͰɺi >= r ʹͳͬͨ࣌୳ࡧΛऴྃ
  30. 33 ໰୊2-2 ૢ࡞Λίʔυʹམͱ͠ࠐΜͰΈΔ • i = 1, r = M(6)

    ◦ r ͷҐஔΛ୳ࡧ͢Δ ▪ r = 6: A[i](50) + A[r](450) = 500ɺN(500)ԁҎԼͳͷͰ r = 6 Ͱܾఆ ◦ औΕΔൣғΛ౴͑ʹՃࢉ͢Δɿr(6) - i(1) = 5 • i = 2, r = 6 ◦ r ͷҐஔΛ୳ࡧ͢Δ ▪ r = 6: A[i](100) + A[r](450) = 550ɺN(500)ԁҎԼΛຬͨ͞ͳ͍ͷͰɺr Λ1 ͭࠨʹͣΒ͢ ▪ r = 5: A[i](100) + A[r](450) = 550ɺN(500)ԁҎԼΛຬͨ͞ͳ͍ͷͰɺr Λ1 ͭࠨʹͣΒ͢ ▪ r = 4: A[i](100) + A[r](300) = 400ɺN(500)ԁҎԼͳͷͰ r = 4 Ͱܾఆ ◦ औΕΔൣғΛ౴͑ʹՃࢉ͢Δɿr(4) - i(2) = 2 ೖྗྫ 500 6 50 100 200 300 450 450
  31. 34 ໰୊2-2 ૢ࡞Λίʔυʹམͱ͠ࠐΜͰΈΔ • i = 3, r = 4

    ◦ r ͷҐஔΛ୳ࡧ͢Δ ▪ r = 4: A[i](200) + A[r](300) = 500ɺN(500)ԁҎԼͳͷͰ r = 4 Ͱܾఆ ◦ औΕΔൣғΛ౴͑ʹՃࢉ͢Δɿr(4) - i(3) = 1 • i = 4, r = 4 ◦ i >= r ͳͷͰɺ୳ࡧΛऴྃ͢Δ ೖྗྫ 500 6 50 100 200 300 450 450
  32. 35 ໰୊2-2 վળͨ͠ίʔυͷܭࢉྔ • վળίʔυ ◦ ϓϨθϯτͷঢॱιʔτɿO(MlogM) ◦ ୳ࡧύʔτ ▪

    i ͸ ࠷େͰ΋ 1 → M ·Ͱ͔͠୳ࡧ͠ͳ͍ɿO(M) ▪ r ͸ ࠷େͰ΋ M → 1 ·Ͱ͔͠୳ࡧ͠ͳ͍ɿO(M) ▪ ݁Ռͱͯ͠ɺO(M) ◦ ʮϓϨθϯτͷঢॱιʔτʯͱʮ୳ࡧύʔτʯͷ࠷େ஋Λݟͯ΋ɿO(MlogM) • ໰୊2-1ͷղ๏ ◦ ܭࢉྔɿO(M^2) • վળίʔυͩͱɺM ͷ࠷େ஋͕ 2×10^5 Ͱ΋ؒʹ߹͏ʂʂ
  33. 36 ໰୊2-2 ٙࣅίʔυྫ (ೖྗ͸ল͖·͢) r = M, answer = 0

    sort(A): ϓϨθϯτͷ஋Λঢॱʹιʔτ͢Δ for: i = 1 ~ M while ʮi < rʯ ͔ͭʮA[i] + A[r] > Nʯ: r -= 1 if: i >= r break(ϧʔϓΛൈ͚Δ) answer += r - i answer Λग़ྗ
  34. 37 ໰୊2-2 ผղ • ୳ࡧύʔτͰʮೋ෼୳ࡧʯͱ͍͏ΞϧΰϦζϜΛ׆༻͢Δ ◦ ϓϨθϯτ͕ঢॱʹฒΜͰ͍Δ͜ͱ͕લఏ ◦ A[2] =

    100 ʹରͯ͠ɺA[i] ͕ 400 ԁ ΑΓେ͖͍ ࠷খͷ i ͷ৔ॴΛ୳ࡧ͢Δ͜ͱ͕Ͱ͖Δ ▪ i = 5(A[i] = 450) ͳͷͰɺA[2] ʹରͯ͠औΕΔൣғ͸ɺ(5 - 1) - 2 = 2 • ͜͜Ͱ (5 - 1) ͱ -1 Λ͍ͯ͠Δͷ͸ɺΑΓେ͖͍஋Λ୳ࡧ͍ͯ͠ΔͨΊɺͦͷҰݸࠨͷཁૉΛݟΔඞཁ ͕͋Δ͔ΒɿA[(5 - 1)] = 400 ◦ ͳͥɺ৚͕݅ A[i] ͕ 400 ԁ ΑΓେ͖͍ ͳͷ͔ʁ400ԁҎ্Ͱ΋ྑ͍ͷͰ͸ʁ ▪ 400ԁҎ্ͩͱɺA[3] = 400 Λऔಘͯ͠͠·͏ͨΊɺಉ͡஋͕͋Δ৔߹ʹΑΓӈଆͷ i Λ୳ࡧͰ͖ͳ͍ͨΊ ೖྗྫ 500 6 50 100 400 400 450 475
  35. 38 ·ͱΊ • ࢴͳͲΛ࢖ͬͯɺखͰૢ࡞ͷखॱΛॻ͖ى͜͠ΈΔ ◦ ʮղ๏ʯ΍ʮίʔυ΁ͷམͱ͠ࠐΈํʯ͕ݟ͑ͯ͘Δ͜ͱ΋ • ༩͑ΒΕͨೖྗʹରͯ͠ɺԿ͔લ४උͰ͖ͳ͍͔ߟ͑ͯΈΔ ◦ ʮঢॱʯ΍ʮ߱ॱʯʹιʔτ͢Δ͜ͱͰૢ࡞ͷखॱΛݮΒͤͨΓ͢Δ

    • ͦͷޙͷ໘઀ʹΑͬͯ͸ɺίʔυͷߟ͑ํΛฉ͔ΕͨΓ͢ΔͷͰɺղ͖ํͷઆ໌͸ݴ͑ΔΑ͏ʹ͓ͯ͜͠͏ ◦ ໰୊1-2 Ͱࠨଆͷ஋Λऔͬͨཧ༝ɺ໰୊2-2 Ͱιʔτͨ͠ཧ༝ͳͲ ◦ ೖྗͷ੍໿͕ΑΓେ͖͘ͳͬͨ࣌ɺͲ͏ͨ͠Βྑ͍͔ʁ • ʮܭࢉྔΛݮΒ͢ʯ͜ͱ͚͕ͩਖ਼ٛͰ͸ͳ͍Ͱ͢ ◦ M ͷ਺͕খ͍͞஋͔͠औΒͳ͍৔߹͸ɺO(M^2) ͱ O(MlogM) ͷ࣮ߦ࣌ؒʹҧ͍͸΄΅ͳ͍Ͱ͢ ▪ ͦ͏͍͏৔߹͸ɺ࣮૷͠΍͍͢ɺݟ΍͍͢ʢσόοά͕͠΍͍͢ʣίʔυΛॻ͖·͠ΐ͏
  36. freeeձܭ freeeਃࠂ freeeਓࣄ࿑຿ freee෱རްੜ freeeձࣾઃཱ freee։ۀ freeeࢿۚௐୡ freeeΧʔυ freeeαΠϯ freeeडൃ஫

    freee޻਺؅ཧ freeeΞϓϦετΞ freeeۈଵ؅ཧPlus freeeൢച freeeొه etc. freee͕ఏڙ͢ΔϓϩμΫτ͸50Ҏ্
  37. 48 εϚϗΞϓϦҰཡ iOS Android iOS Android iOS Android iOS Android

    iOS Android freeeձܭ freeeਓࣄ࿑຿ freeeձࣾઃཱ freee޻਺؅ཧ freee੥ٻॻ ※ͦͷଞɺfreeeిࢠਃࠂɾਃ੥ɺfreeeೖग़ۚ؅ཧɺfreeeަ௨අਫ਼ࢉͷωΠςΟϒΞϓϦ͕ଘࡏ͠·͢
  38. Notes: 1. Annual Recurring RevenueɻMRR(Monthly Recurring Revenue)Λ12ഒͯ͠ࢉग़ɻMRR͸ର৅݄ͷ݄຤࣌఺ʹ͓͚Δܧଓ՝ۚϢʔβʔاۀʹ܎Δֹ݄ྉۚͷ߹ܭֹ(Ұ࣌ऩӹ͸ؚ·ͳ͍) 2. ༗ྉ՝ۚϢʔβʔاۀ਺ɿ౰ࣾάϧʔϓͷαʔϏεΛར༻͢Δݸਓࣄۀओͱ๏ਓͷ૒ํΛࢦ͢ 3.

    ैۀһ਺͸2021೥6݄ɺ2023೥6݄࣌఺ͷ΋ͷΛܝࡌ 2೥લ 2021೥12݄ ݱࡏ 2023೥12݄ ೥ؒܦৗऩӹ ʢARRʣ ༗ྉ՝ۚ Ϣʔβʔ਺(2) ैۀһ਺ 128 ԯԁ 232 ԯԁ 32ສࣾ 47 ສࣾ+ 726 ໊ 1,299໊ ϢʔβʔՁ஋Λ௥ٻ͠ɺνϟϨϯδ͠ଓ͚Δ͜ͱͰٸ੒௕