Submission #620163

# Submission time Handle Problem Language Result Execution time Memory
620163 2022-08-03T02:44:34 Z drdilyor Distributing Candies (IOI21_candies) C++17
3 / 100
5000 ms 10568 KB
#include <bits/stdc++.h>
#include"candies.h"
#ifdef ONPC
    #include "t_debug.cpp"
#else
    #define debug(...) 42
#endif
#define sz(a) ((int)(a).size())
using namespace std;
using ll = long long;
const int INF = 1e9;
const ll INFL = 1e18;
const int RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
mt19937 rng(RANDOM);
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U>& p) { return is >> p.first >> p.second; }
const int N = 2e5, LOGN = 17, MOD = 1e9+7;

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

    vector<int> res(n);
    for (int i = 0; i < n; i++) {
        int low = 0;
        for (int j = 0; j < q; j++) {
            if (!(l[j] <= i && i <= r[j])) continue;
            res[i] += v[j];
            if (res[i] > low + c[i]) {
                low = res[i] - c[i];
            } else if (res[i] < low) {
                low = res[i];
            }
        }
        res[i] -= low;
    }
    return res;
}
/*
     █████               █████  ███  ████                               
    ▒▒███               ▒▒███  ▒▒▒  ▒▒███                               
  ███████  ████████   ███████  ████  ▒███  █████ ████  ██████  ████████ 
 ███▒▒███ ▒▒███▒▒███ ███▒▒███ ▒▒███  ▒███ ▒▒███ ▒███  ███▒▒███▒▒███▒▒███
▒███ ▒███  ▒███ ▒▒▒ ▒███ ▒███  ▒███  ▒███  ▒███ ▒███ ▒███ ▒███ ▒███ ▒▒▒ 
▒███ ▒███  ▒███     ▒███ ▒███  ▒███  ▒███  ▒███ ▒███ ▒███ ▒███ ▒███     
▒▒████████ █████    ▒▒████████ █████ █████ ▒▒███████ ▒▒██████  █████    
 ▒▒▒▒▒▒▒▒ ▒▒▒▒▒      ▒▒▒▒▒▒▒▒ ▒▒▒▒▒ ▒▒▒▒▒   ▒▒▒▒▒███  ▒▒▒▒▒▒  ▒▒▒▒▒     
                                            ███ ▒███                    
                                           ▒▒██████                     
                                            ▒▒▒▒▒▒
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 12 ms 408 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5078 ms 10568 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1853 ms 8036 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 Correct 1670 ms 5028 KB Output is correct
4 Correct 871 ms 2692 KB Output is correct
5 Execution timed out 5015 ms 7276 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 320 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 12 ms 408 KB Output is correct
6 Execution timed out 5078 ms 10568 KB Time limit exceeded
7 Halted 0 ms 0 KB -