답안 #894840

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
894840 2023-12-29T05:44:51 Z Muhammad_Aneeq 사탕 분배 (IOI21_candies) C++17
0 / 100
5000 ms 13396 KB
#include <vector>
using namespace std;
int const N=2e5+10;
int n;
vector<int> distribute_candies(vector<int> c, vector<int> l,vector<int> r, vector<int> v)
{
    n=c.size();
    bool w=0;
    for (auto i:v)
        if (i<0)
            w=1;
    if (w==0)
    {
        vector<long long>d(n+1,0);
        for (int i=0;i<l.size();i++)
        {
            d[l[i]]+=v[i];
            d[r[i]+1]-=v[i];
        }
        vector<int>ans;
        ans.push_back(d[0]);
        for (int i=1;i<n;i++)
            ans.push_back(d[i]-ans.back());
        for (int i=0;i<n;i++)
        {
            ans[i]=(ans[i]<0?0:ans[i]);
            ans[i]=min(c[i],ans[i]);
        }
        return ans;
    }
    vector<int>ans(n,0);
    for (int i=0;i<l.size();i++)
    {
        for (int j=l[i];j<=r[i];j++)
        {
            ans[j]+=v[i];
            ans[j]=min(ans[j],c[j]);
            ans[j]=(ans[j]<0?0:ans[j]);
        }
    }
    return ans;
}

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:15:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |         for (int i=0;i<l.size();i++)
      |                      ~^~~~~~~~~
candies.cpp:32:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for (int i=0;i<l.size();i++)
      |                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 78 ms 9312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 162 ms 8160 KB Output is correct
3 Correct 166 ms 6016 KB Output is correct
4 Execution timed out 5021 ms 13396 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 408 ms 5096 KB Output is correct
4 Correct 427 ms 2900 KB Output is correct
5 Execution timed out 5032 ms 7384 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -