답안 #434997

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
434997 2021-06-22T18:41:05 Z MilosMilutinovic 사탕 분배 (IOI21_candies) C++17
3 / 100
5000 ms 10564 KB
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define vi vector<int>
#define pi pair<int, int>
#define mod 998244353
template<typename T> bool chkmin(T &a, T b){return (b < a) ? a = b, 1 : 0;}
template<typename T> bool chkmax(T &a, T b){return (b > a) ? a = b, 1 : 0;}
ll ksm(ll a, ll b) {if (b == 0) return 1; ll ns = ksm(a, b >> 1); ns = ns * ns % mod; if (b & 1) ns = ns * a % mod; return ns;}
using namespace std;

const int maxn = 200005;
int n, q;
vi a(maxn);

vi brute_force(vi c, vi l, vi r, vi v) {
    for (int i = 0; i < q; i++) {
        for (int j = l[i]; j <= r[i]; j++) {
            if (v[i] > 0) a[j] = min(c[j], a[j] + v[i]);
            else a[j] = max(0, a[j] + v[i]);
        }
    }
    return a;
}

vi distribute_candies(vi c, vi l, vi r, vi v) {
    n = (int) c.size();
    q = (int) l.size();
    a.resize(n);
    if (n <= 1000 && q <= 1000) {
        return brute_force(c, l, r, v);
    }
}

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:36:1: warning: control reaches end of non-void function [-Wreturn-type]
   36 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 2 ms 1100 KB Output is correct
4 Correct 2 ms 1100 KB Output is correct
5 Correct 4 ms 1100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5060 ms 10480 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1100 KB Output is correct
2 Correct 237 ms 8180 KB Output is correct
3 Correct 224 ms 4612 KB Output is correct
4 Execution timed out 5094 ms 10564 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 1100 KB Output is correct
3 Correct 554 ms 8168 KB Output is correct
4 Correct 542 ms 4256 KB Output is correct
5 Execution timed out 5060 ms 10436 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 972 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 2 ms 1100 KB Output is correct
4 Correct 2 ms 1100 KB Output is correct
5 Correct 4 ms 1100 KB Output is correct
6 Execution timed out 5060 ms 10480 KB Time limit exceeded
7 Halted 0 ms 0 KB -