Блог пользователя atcoder_official

Автор atcoder_official, история, 19 месяцев назад, По-английски

We will hold KEYENCE Programming Contest 2024(AtCoder Beginner Contest 374).

We are looking forward to your participation!

  • Проголосовать: нравится
  • +40
  • Проголосовать: не нравится

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится +7 Проголосовать: не нравится

hope that I can get to 1200 this time

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

But why is the page of ABC374 red?

All other competition pages are normal.

Maybe it's an important contest?

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Good luck! And have fun!

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hope that I can get to 1750 this time.

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

Why is the page of ABC374 red?

Because Chinese National Day?

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

hope to AC at least 5 problems

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hope that I can get to 1400 this time.

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I hope F and G will be not abstract

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hope that I can get to -114514 this time!!!

I'm not strong enough...

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Most of people here are Chinese(including me)!————Happy National Day!

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

How to solve problem E? Is it some well known problem?

  • »
    »
    19 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится +13 Проголосовать: не нравится

    Let's find the minimal cost for $$$i$$$-th process to produce $$$y$$$ products. Assume we bought $$$i$$$ machines of first type and $$$j$$$ machines of second type.

    $$$a \cdot i + b \cdot j \ge y$$$

    $$$p \cdot i + q \cdot j \rightarrow min$$$

    Let the first type of machine be "better" than the second: $$$\frac{a}{p} \ge \frac{b}{q}$$$. If we could buy fraction of machine, then we would use only the first type. But it can be the case, that we it is more effective to buy the second type machine (for example, if it is not effective, but we need only one last product, while the first type machine produces a lot).

    There is one quite known fact: $$$j$$$ is limited by some number. If we have $$$b \cdot (\alpha + \beta)$$$, where $$$j = \alpha + \beta$$$ and $$$b \cdot \alpha$$$ is divisible by $$$a$$$, then we can increase $$$i$$$ by $$$\frac{b \cdot \alpha}{a}$$$ and decrease $$$j$$$ by $$$\alpha$$$. This means, that $$$j$$$ is not greater, than $$$max(a, b)$$$ (in these case, it is possible to choose such $$$\alpha$$$, which is equal to $$$a$$$, so $$$b \cdot \alpha$$$ will be divisible by $$$a$$$).

    So we just check all possible $$$j$$$ from $$$0$$$ to $$$max(a, b)$$$.

    For the whole problem. Use binary search on answer and in check function calculate sum if all these $$$p \cdot i + q \cdot j \rightarrow min$$$ and check if it is not greater than $$$x$$$.

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Guys solution for problem C?

  • »
    »
    19 месяцев назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    2 ways to do that, both ways involve trying out all possibilities (Notice that N is small here)

    • Backtracking to try both groups for every department.
    • Enumerating all bitmasks which represent which departments will be in group 1 (The bit is off) or group 2 (The bit is on) (For example, if N is 5, a bitmask of 01010 means the first, third and fifth departments will be in group 1, the second and fourth departments will be in group 2).
»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

in E why the machine costing higher price per product will be atmost 100

check the code of jiangly Link

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can anyone prove why this solution for E is right? I thought it might have been hacked.

The idea is to purchase mostly the 'better' machine, and enumerate the number of the 'worse' machine from 0 to 15000.

Submission: https://atcoder.jp/contests/abc374/submissions/58472647

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

https://atcoder.jp/contests/abc374/submissions/58486583 This is my submission for problem D. Can someone help me check why my solution doesn't even pass the sample inputs? When I run it on my compiler the solution matches with the sample solutions. Thank you!

  • »
    »
    19 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится
    Spoiler
  • »
    »
    19 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Please remove extra cout << ' ' statements.

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

can anyone tell what was the logic on e

i applied ternary search on a binary search but some test cases are giving wrong My submission link

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I failed to construct a checker function for my binary search on E, how can I do this?

»
19 месяцев назад, скрыть # |
Rev. 3  
Проголосовать: нравится +6 Проголосовать: не нравится

Why My Code got Wrong Answer in question E? I can't hack it, Can anyone help me to hack it? It works very well on random datas.

My solution is for each process $$$i$$$, for every $$$a_i \times b_i$$$ product, it is definitely better to choose either all $$$S_i$$$machines or all $$$T_i$$$ machines. The remaining part should not exceed $$$10^4$$$, so it can be solved by brute force.

»
19 месяцев назад, скрыть # |
Rev. 3  
Проголосовать: нравится +1 Проголосовать: не нравится

I got the solution for E!

For every process i, it is always beneficial to greedily buy the machine with the better output / cost ratio.

So buy that machine as much as possible, and the remainder products needed will be < 100. Now buy the other machine to fill this remainder.

Worst case, the remainder is 99 and the other machine's output is 1, so the quantity we buy will be 99. Thats why the max quantity we will buy of this machine is approx 100.

Submission for reference

  • »
    »
    19 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    This is the same as jiangly's idea, Can you prove why it's beneficial to use ratio $$$a_i / p_i$$$ and $$$b_i / q_i$$$?

  • »
    »
    19 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    For every process i, it is always beneficial to greedily buy the machine with the better output / cost ratio.

    So buy that machine as much as possible, and the remainder products needed will be < 100. Now buy the other machine to fill this remainder.

    Both the statements are incorrect. You just got lucky with your code, because you haven't implemented what you are thinking. Your code is correct though.

    Greedily buying efficient machines as much as possible is not optimal. In fact, as counter intuitive as it may seem, you need to buy inefficient machines first (explore all possibility instead of buying greedily) and only then should you buy efficient machines.

    I talk about a counter example to your idea in my video

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I screwed myself in E trying to answer the minimum cost for each pair to reach mid in O(1). I don't know why I didn't just loop since the constraints are low.

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Finally, I (would) reach yellow through get a 2400 perf in this contest.

I have struggled 4 years since I play my first contest in AtCoder.

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

anyone please tell me problem c approach?

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Will there be english tutorial later? I'd like to check the solution for F and G.

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can somebody explain please why production capacity in sample#1 of task "E" is 4 if W=min(W1, W2, W3, W4) => W=min(4, 1, 3, 4) = 1, hence production capacity should be 1, not 4?

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится +11 Проголосовать: не нравится

https://www.youtube.com/watch?v=6-w832UQfL4&t=1s I recently created a youtube channel to discuss atcoder solutions. Here's the link for anyone who wants to watch it. It's only my second video so it might not be very good, but I'd be happy if anyone can give me advice!

»
19 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится +8 Проголосовать: не нравится

My F solution is different from official editorial:

$$$\text{dp[i][j] = {minimum answer, minimum time of last shipment}}$$$

when considering the first $$$i$$$ orders and we shipped the last $$$j$$$ of them together.

Time complexity: $$$\mathcal{O}(NK^2)$$$ if you optimize calculating disatisfaction to $$$\mathcal{O}(1)$$$.

I initially tried the DP without the 2nd dimension, but it failed. Why do we need the 2nd dimension, or weak tests?

»
19 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Fail to debug E :(