Submission #446196

# Submission time Handle Problem Language Result Execution time Memory
446196 2021-07-21T08:08:53 Z arnold518 Distributing Candies (IOI21_candies) C++17
3 / 100
5000 ms 14532 KB
#include "candies.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAXN = 2e5;
const ll INF = 1e18;

struct Query
{
    int l, r, v;
};

int N, Q;
int A[MAXN+10];
Query B[MAXN+10];
int ans[MAXN+10];



vector<int> distribute_candies(vector<int> _C, vector<int> _L, vector<int> _R, vector<int> _V)
{
    N=_C.size(); Q=_L.size();
    for(int i=1; i<=N; i++) A[i]=_C[i-1];
    for(int i=1; i<=Q; i++) B[i]={_L[i-1]+1, _R[i-1]+1, _V[i-1]};

    for(int i=1; i<=Q; i++)
    {
        for(int j=B[i].l; j<=B[i].r; j++)
        {
            ans[j]+=B[i].v;
            ans[j]=max(ans[j], 0);
            ans[j]=min(ans[j], A[j]);
        }
    }

    return vector<int>(ans+1, ans+N+1);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 3 ms 372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5066 ms 10436 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 219 ms 10464 KB Output is correct
3 Correct 213 ms 7572 KB Output is correct
4 Execution timed out 5073 ms 14532 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 508 ms 8160 KB Output is correct
4 Correct 505 ms 5556 KB Output is correct
5 Execution timed out 5086 ms 13932 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 2 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 3 ms 372 KB Output is correct
6 Execution timed out 5066 ms 10436 KB Time limit exceeded
7 Halted 0 ms 0 KB -