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

Автор chokudai, история, 7 лет назад, По-английски

We will hold AtCoder Beginner Contest 153.

The point values will be 100-200-300-400-500-600.

We are looking forward to your participation!

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

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

What's wrong?

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

Who know how to do E?

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится -20 Проголосовать: не нравится

Question E and question F can be done if you think about them.Come on!!!

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

I like this kind of "to simple contest", allways makes me feel like a champion!

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

How to solve Question E?? Thanks in Advance

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

how to solve F? anyone please.

»
7 лет назад, скрыть # |
← Rev. 9  
Проголосовать: нравится +12 Проголосовать: не нравится

Editorial By Gary2005

A
B
C
D
E
F

All of my submissions. ( https://atcoder.jp/contests/abc153/submissions?f.User=Gary)

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

Surprised to see an easy F. Also my E passed, but I am using $$$H*10^4$$$ operations, which means $$$10^8$$$ operations in worst case. Was this intended to pass?

https://atcoder.jp/contests/abc153/submissions/9758669

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

Can anyone explained more details how to solve problem E ? thanks in advance !

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

I couldn't solve E for 87 minutes and it was because I was so impatient, trying out greedy solutions that I assumed would work and not waiting or thinking long enough before I implemented.

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Problem F: Can someone please find what's wrong in this code? I have used two pointer to solve it.

int n,d,a;
cin>>n>>d>>a;
vector<pair<int,int>> v(n);
for(int i=0;i<n;i++)
cin>>v[i].first>>v[i].second;
sort(v.begin(),v.end());
if(d==0)
{
	int total=0;
	for(pii i : v)
	total+=i.se;
	cout<<total;
	return;
}
int d1=(v[0].se+a-1)/a,r=v[0].f+2*d;
int cost=d1;int ptr=-1;int i=0;
while(i<=n-1)
{
	if(v[i].f<=r)
	{
		v[i].se-=d1*a;
		if(v[i].se>0)
		if(ptr==-1)
		ptr=i;
		vis[i]=1;
	}
	else
	{
		if(ptr==-1)
		ptr=i;
		d1=(v[ptr].se+a-1)/a;r=v[ptr].f+2*d;
		cost+=d1;
		i=ptr-1;
		ptr=-1;
	}
   	i++;
}
cout<<cost;
»
7 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

What's wrong in this solution of F?
link

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

As a monster, I feel violated by this round.

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

Submission

Can someone please explain why this times out even after using memoization?

  • »
    »
    7 лет назад, скрыть # ^ |
    ← Rev. 3  
    Проголосовать: нравится +3 Проголосовать: не нравится

    You have $$$O(NH)$$$ states. For each state you do $$$O(H)$$$ calculations, so the overall complexity is $$$O(NH^2)$$$, which is not feasible for the given constraints.

    You can calculate the answer for each state in $$$O(1)$$$, so the overall complexity will be $$$O(NH)$$$. Replace the while loop with:

    dp[i][h] = min(solve(h, i + 1, n), solve(h - a[i], i, n) + b[i]);
    

    solve(h, i + 1, n) indicates that we decide not to use spell i.
    solve(h - a[i], i, n) + b[i] indicates that we use spell i. Note, that we don't advance to the next spell yet, because we may want to use spell i several times, and this allows us to avoid using the while loop.

    Sidenote: It is actually possible to "squeeze" your solution. Notice, that if all a[i] were different, the total complexity would improve from $$$O(NH^2)$$$ to $$$O(H^2\log H)$$$, by the Harmonic series argument (see this or this). And for this problem it is possible to make all a[i] different, because for each unique a[i] we are only interested in the smallest cost b[i]. See this submission, which barely fits in the 2s TL with a couple of optimizations.

    Edit: I just realized that the complexity of the second solution is probably $$$O(H^2\log H)$$$ rather than $$$O(NH\ log H)$$$.

»
7 лет назад, скрыть # |
← Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Why does this solution to problem F fail?

I reckon that there is no problem with the main part...

Link

Maybe it's the sqrt decomposition part? I copied it from a template...

(The complexity is $$$O(n\sqrt{n}\log n )$$$, should be able to pass...)

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

Am I only one here solve F using Segment Tree? Is it overkill?

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

fought many monsters in this contest