Submission #824780

# Submission time Handle Problem Language Result Execution time Memory
824780 2023-08-14T10:02:53 Z andrei_boaca Distributing Candies (IOI21_candies) C++17
11 / 100
88 ms 13764 KB
#include "candies.h"
#include <bits/stdc++.h>
#include <vector>
//#include "grader.cpp"
using namespace std;
typedef long long ll;
int n,q;
vector<ll> v;
vector<int> sol;
std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> stanga,std::vector<int> dreapta, std::vector<int> vals)
{
    n = c.size();
    q=stanga.size();
    v.resize(n);
    sol.resize(n);
    if(n<=2000&&q<=2000)
    {
        for(int z=0;z<stanga.size();z++)
        {
            int l=stanga[z];
            int r=dreapta[z];
            int val=vals[z];
            for(int i=l;i<=r;i++)
            {
                v[i]+=val;
                if(v[i]<0)
                    v[i]=0;
                if(v[i]>c[i])
                    v[i]=c[i];
            }
        }
        for(int i=0;i<v.size();i++)
            sol[i]=v[i];
        return sol;
    }
    bool ok=1;
    for(int i=0;i<vals.size();i++)
        if(vals[i]<0)
            ok=0;
    if(ok)
    {
        for(int z=0;z<vals.size();z++)
        {
            int l=stanga[z];
            int r=dreapta[z];
            int val=vals[z];
            v[l]+=val;
            if(r+1<n)
                v[r+1]-=val;
        }
        ll suma=0;
        for(int i=0;i<n;i++)
        {
            suma+=v[i];
            sol[i]=min(suma,1LL*c[i]);
        }
        return sol;
    }
    return sol;
}

Compilation message

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:18:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         for(int z=0;z<stanga.size();z++)
      |                     ~^~~~~~~~~~~~~~
candies.cpp:32:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |         for(int i=0;i<v.size();i++)
      |                     ~^~~~~~~~~
candies.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i=0;i<vals.size();i++)
      |                 ~^~~~~~~~~~~~
candies.cpp:42:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         for(int z=0;z<vals.size();z++)
      |                     ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 88 ms 9660 KB Output is correct
2 Correct 78 ms 13764 KB Output is correct
3 Correct 78 ms 13548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 40 ms 4960 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Incorrect 41 ms 4964 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 324 KB Output is correct
6 Correct 88 ms 9660 KB Output is correct
7 Correct 78 ms 13764 KB Output is correct
8 Correct 78 ms 13548 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Incorrect 40 ms 4960 KB Output isn't correct
11 Halted 0 ms 0 KB -