Submission #796703

# Submission time Handle Problem Language Result Execution time Memory
796703 2023-07-28T15:52:58 Z Minindu206 Distributing Candies (IOI21_candies) C++17
0 / 100
86 ms 12120 KB
#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
 
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
    int n = c.size(), q = l.size();
    vector<int> candies(n, 0);
    if(n <= 2000 & q <= 2000)
    {
        for(int i=0;i<q;i++)
        {
            int ll = l[i], rr = r[i];
            while(ll >= rr)
            {
                candies[ll] += v[i];
                if(candies[ll] > c[ll])
                    candies[ll] = c[ll];
                if(candies[ll] < 0)
                    candies[ll] = 0;
                ll++;
            }
        }
        return candies;
    }
    else
    {
        int ans = 0;
        for(int val:v)
            ans += val;
        for(int i=0;i<n;i++)
            candies[i] = min(ans, c[i]);
        return candies;
    }
}

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:8:10: warning: suggest parentheses around comparison in operand of '&' [-Wparentheses]
    8 |     if(n <= 2000 & q <= 2000)
      |        ~~^~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 86 ms 12120 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -