Submission #720994

# Submission time Handle Problem Language Result Execution time Memory
720994 2023-04-10T02:17:09 Z n0sk1ll Distributing Candies (IOI21_candies) C++17
3 / 100
114 ms 11348 KB
#include <bits/stdc++.h>

#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0)
#define mp make_pair
#define xx first
#define yy second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(x) x.begin(),x.end()
#define ff(i,a,b) for (int i = a; i < b; i++)
#define fff(i,a,b) for (int i = a; i <= b; i++)
#define bff(i,a,b) for (int i = b-1; i >= a; i--)
#define bfff(i,a,b) for (int i = b; i >= a; i--)

using namespace std;
long double typedef ld;
unsigned int typedef ui;
long long int typedef li;
pair<int,int> typedef pii;
pair<li,li> typedef pli;
pair<ld,ld> typedef pld;
vector<vector<int>> typedef graph;
unsigned long long int typedef ull;
//const int mod = 998244353;
//const int mod = 1000000007;







//Note to self: Check for overflow

vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v)
{
    int n=(int)c.size();
    int q=(int)v.size();

    if (n<=3000 && q<=3000)
    {
        vector<int> stored(n,0);
        ff(qq,0,q)
        {
            fff(i,l[qq],r[qq]) stored[i]+=v[qq];
            fff(i,l[qq],r[qq]) stored[i]=max(stored[i],0);
            fff(i,l[qq],r[qq]) stored[i]=min(stored[i],c[i]);
        }
        return stored;
    }
    else
    {
        return c;
    }
}

/*int main()
{
    vector<int> c,l,r,v;
    int n; cin>>n;
    ff(i,0,n)
    {
        int x; cin>>x;
        c.pb(x);
    }

    int q; cin>>q;
    while (q--)
    {
        int ll,rr,vv; cin>>ll>>rr>>vv;
        l.pb(ll),r.pb(rr),v.pb(vv);
    }

    vector<int> ans=distribute_candies(c,l,r,v);
    for (auto it : ans) cout<<it<<" "; cout<<endl;
}*/

//Note to self: Check for overflow
# Verdict Execution time Memory Grader output
1 Correct 1 ms 260 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 4 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 114 ms 11348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 51 ms 8012 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 55 ms 7636 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 260 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 4 ms 340 KB Output is correct
6 Incorrect 114 ms 11348 KB Output isn't correct
7 Halted 0 ms 0 KB -