제출 #444591

#제출 시각아이디문제언어결과실행 시간메모리
444591KiriLL1ca사탕 분배 (IOI21_candies)C++17
11 / 100
129 ms10248 KiB
#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;
}
*/

컴파일 시 표준 에러 (stderr) 메시지

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 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...