Pagini: [1]   În jos
  Imprimă  
Ajutor Subiect: 087 Gard  (Citit de 2987 ori)
0 Utilizatori şi 1 Vizitator pe acest subiect.
domino
Echipa infoarena
Nu mai tace
*****

Karma: 281
Deconectat Deconectat

Mesaje: 1.340



Vezi Profilul WWW
« : August 30, 2005, 00:23:17 »

Aici puteţi discuta despre problema Gard.
Memorat
Marius
Nu mai tace
*****

Karma: 154
Deconectat Deconectat

Mesaje: 572



Vezi Profilul
« Răspunde #1 : Februarie 04, 2006, 20:50:43 »

ce complexitate ati gasit la problema asta ? eu am N * N * K, ceea ce e destul de mult...  Sad  cum pot sa scap de un N ?
Memorat

Faceti lucrurile simplu: pe cat de simplu posibil, dar nu mai simplu.
u-92
Vizitator
« Răspunde #2 : Februarie 04, 2006, 20:57:01 »

cu cateva observatii utile devine N*K Tongue
daca nu te prinzi, problema asta a fost data la oni 2002 la baraj (dupa cum scrie si in enunt Smile )
Memorat
hendrik
Strain


Karma: 11
Deconectat Deconectat

Mesaje: 6



Vezi Profilul
« Răspunde #3 : Iulie 08, 2010, 10:24:37 »

Hi,
I am stuck in this problem  sad, could someone explain how to solve it in O(N*K)?

Thanks

Hi,
I am stuck in this problem  sad, could someone explain how to solve it in O(N*K)?

Thanks
any body here? Please help me Cry

It would be nice if you would edit your previous messages when consecutively posting on the same subject.

ah.. sorry for that. Ok I will do it from now on. Thx for the advice
« Ultima modificare: Iulie 12, 2010, 13:45:06 de către Hendrik Lai » Memorat
SpiderMan
Nu mai tace
*****

Karma: -463
Deconectat Deconectat

Mesaje: 937



Vezi Profilul
« Răspunde #4 : Iulie 12, 2010, 09:26:34 »

I can give you the official source, if it helps you  wink
Memorat
hendrik
Strain


Karma: 11
Deconectat Deconectat

Mesaje: 6



Vezi Profilul
« Răspunde #5 : Iulie 12, 2010, 11:14:09 »

hm.. thx for replying Smile. I would be happy if someone can give me some hints and I tried it myself  Confused
Memorat
pauldb
Nu mai tace
*****

Karma: 821
Deconectat Deconectat

Mesaje: 1.901



Vezi Profilul
« Răspunde #6 : Iulie 12, 2010, 12:09:53 »

I can't remember the exact details, but you should use a deque in order to improve the DP to run in O(N*K). If this hint is doesn't help you enough, I'll think of the problem in a couple of days and post a more detailed solution.
Memorat

Am zis Mr. Green
hendrik
Strain


Karma: 11
Deconectat Deconectat

Mesaje: 6



Vezi Profilul
« Răspunde #7 : Iulie 21, 2010, 01:48:27 »

I can't remember the exact details, but you should use a deque in order to improve the DP to run in O(N*K). If this hint is doesn't help you enough, I'll think of the problem in a couple of days and post a more detailed solution.
hm.. I still don't get the idea how to solve it with a deque Sad Further helps needed Smile
Memorat
stardust
Strain
*

Karma: 13
Deconectat Deconectat

Mesaje: 39



Vezi Profilul
« Răspunde #8 : August 24, 2012, 19:24:08 »

Salut ! Am nevoie de putin ajutor la problema asta. Eu m-am gandit asa. dp[ i ][j] - suma maxima ce se poate obtine daca ultima scandura vopsita de muncitorul i este j. Doar ca ma incurc cand trebuie sa fac deque-ul. De fapt, mai general, chestia e urmatoarea : am un vector cu n numere. Si pentru o pozitie fixata x stiu ca pot sa merg inapoi y pozitii. Imi trebuie maximul dintre a[x-i]+c*i, unde c constat si 1<=i<=y. Se poate face asta cu deque ? Si daca da cum ?

Si daca nu se poate cam cum ar trebui rezolvata problema ?
Memorat
tzipleatud
De-al casei
***

Karma: 104
Deconectat Deconectat

Mesaje: 117



Vezi Profilul
« Răspunde #9 : August 25, 2012, 00:02:27 »

Salut! Nu am facut problema asta, dar cred ca iti pot raspunde la intrebarea ta in legatura cu deque. Avand in vedere ca fiecare element "creste" constant cu C, la fiecare pas, rezulta ca ordinea elementelor din deque nu se va modifica. Uite o portiune de cod:

Cod:

#include <iostream>
#include <deque>

using namespace std;

int N,i,C,Y;
int A[1010];
deque<int> D;

int main ()
{
    cin >> N >> C >> Y;
    for (i=1; i<=N; i++)
        cin >> A[i];

    for (i=1; i<=N; i++)
    {
        while (!D.empty() && A[D.back()]+C*(i-D.back())<=A[i]) D.pop_back(); //scot cat timp A[i] reprezinta o solutie mai buna
        while (!D.empty() && i-D.front()>Y) D.pop_front(); // scot cat timp solutia nu se afla in intervalul [X-Y,X]
        D.push_back(i);
        cout << "Maximul la pozitia " << i << " este " << (A[D.front()]+C*(i-D.front())) << '\n';
    }

    return 0;
}


Cam asa ceva ar veni, sper ca nu am gresit nimic. Bafta! Smile
Memorat
Pagini: [1]   În sus
  Imprimă  
 
Schimbă forumul:  

Powered by SMF 1.1.19 | SMF © 2006-2013, Simple Machines