답안 #444591

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
444591 2021-07-14T10:05:22 Z KiriLL1ca 사탕 분배 (IOI21_candies) C++17
11 / 100
129 ms 10248 KB
#include <bits/stdc++.h>
#define all(X) X.begin(), X.end()
#define rall(X) X.rbegin(), X.rend()
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) (int)x.size()
#define fr first
#define sc second
#define endl '\n'
#define pb push_back
#define pf push_front

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;

const int maxn = 2e5 + 10;

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

    bool subtask1 = (q <= 3000 && n <= 3000);
    bool subtask2 = true, subtask3 = true;

    for (int i = 0; i < q; i++) {
        if (v[i] < 0) {
            subtask2 = false;
        }
    }

    for (int i = 1; i < n; i++) {
        if (c[i] != c[0]) {
            subtask3 = false;
        }
    }

    if (subtask1) {
        for (int i = 0; i < q; i++) {
            for (int j = l[i]; j <= r[i]; j++) {
                if (v[i] > 0) {
                    ans[j] = min(ans[j] + v[i], c[j]);
                }
                else {
                    ans[j] = max(0, ans[j] + v[i]);
                }
            }
        }
        return ans;
    }
    if (subtask2) {
        vector <ll> pref (n + 1);
        for (int i = 0; i < q; i++) {
            pref[l[i]] += v[i];
            pref[r[i] + 1] -= v[i];
        }
        ll cur = 0;
        for (int i = 0; i < n; i++) {
            cur += pref[i];
            ans[i] = min(cur, (ll)c[i]);
        }
        return ans;
    }
}
/*
int32_t main ()
{
    int n, q; cin >> n >> q;
    vector <int> c (n), l (q), r(q), v(q);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    for (int i = 0; i < q; i++) {
        cin >> l[i] >> r[i] >> v[i];
    }
    vector <int> w = distribute_candies(c, l, r, v);
    for (auto i : w) {
        cout << i << " ";
    }
	return 0;
}
*/

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:32:27: warning: variable 'subtask3' set but not used [-Wunused-but-set-variable]
   32 |     bool subtask2 = true, subtask3 = true;
      |                           ^~~~~~~~
candies.cpp:72:1: warning: control reaches end of non-void function [-Wreturn-type]
   72 | }
      | ^
# 결과 실행 시간 메모리 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 9 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 129 ms 8892 KB Output is correct
2 Correct 124 ms 10152 KB Output is correct
3 Correct 121 ms 10248 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 62 ms 4960 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 59 ms 4956 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 9 ms 364 KB Output is correct
6 Correct 129 ms 8892 KB Output is correct
7 Correct 124 ms 10152 KB Output is correct
8 Correct 121 ms 10248 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Incorrect 62 ms 4960 KB Output isn't correct
11 Halted 0 ms 0 KB -