Submission #836772

# Submission time Handle Problem Language Result Execution time Memory
836772 2023-08-24T15:34:42 Z oscar1f Distributing Candies (IOI21_candies) C++17
0 / 100
85 ms 15024 KB
#include<bits/stdc++.h>
#include "candies.h"

using namespace std;
using ll=long long;

const int TAILLE_MAX=200*1000+5;
int nbVal,nbReq;
vector<int> capa,debReq,finReq,typeReq;
vector<int> rep;

vector<int> distribute_candies(vector<int> c,vector<int> l,vector<int> r,vector<int> v) {
    capa=c;
    debReq=l;
    finReq=r;
    typeReq=v;
    nbVal=capa.size();
    nbReq=typeReq.size();
    rep.resize(nbVal);
    ll val=0,deb=0;
    for (int i=0;i<nbReq;i++) {
        if (typeReq[i]>0) {
            val+=typeReq[i];
            deb=max(deb,val);
        }
        else {
            val+=typeReq[i];
            if (val<=0) {
                val=0;
                deb=0;
            }
        }
    }
    for (int j=0;j<nbVal;j++) {
        if (capa[j]>=deb) {
            rep[j]=val;
        }
        else {
            rep[j]=max(val-(deb-capa[j]),(ll)0);
        }
        //cout<<rep[j]<<" ";
    }
    //cout<<endl;
    /*for (int ireq=0;ireq<nbReq;ireq++) {
        for (int i=debReq[ireq];i<=finReq[ireq];i++) {
            if (typeReq[ireq]>0) {
                rep[i]=min(capa[i],rep[i]+typeReq[ireq]);
            }
            else {
                rep[i]=max(0,rep[i]+typeReq[ireq]);
            }
        }
        for (int i:rep) {
            cout<<i<<" ";
        }
        cout<<endl;
    }*/
    return rep;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 15024 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 300 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -