Submission #832054

#TimeUsernameProblemLanguageResultExecution timeMemory
832054vqpahmadDistributing Candies (IOI21_candies)C++17
0 / 100
85 ms8408 KiB
#include<bits/stdc++.h> #include "candies.h" using namespace std; #define ll long long #define pii pair<int,int> #define F first #define S second #define endl '\n' #define pb push_back #define sz(a) (int)a.size() #define all(a) a.begin(),a.end() const int mod = 1e9 + 7; const int N = 1e6 + 15; const ll inf = 1e18; vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) { int n = c.size(); vector<int> s(n); int q = sz(v); int sub1 = (n<=2000&&q<=2000); int sub2 = 1; int sub3 = 1; int sub4 = 1; for (auto it : v){ if (it < 0) sub2 = 0; } for (int i=1;i<n;i++){ sub3 &= c[i]==c[i-1]; } for (int i=0;i<q;i++){ sub4 &= l[i]==0&&r[i]==n-1; } if (sub1){ for (int i=0;i<q;i++){ for (int k=l[i];k<=r[i];k++){ s[k] += v[i]; s[k] = max(0,s[k]); s[k] = min(0,c[k]); } } } else if (sub2){ vector<int> prf(n+1,0); for (int i=0;i<q;i++){ prf[l[i]]+=v[i]; prf[r[i]+1]-=v[i]; } for (int i=1;i<=n;i++){ prf[i] += prf[i-1]; } for (int i=0;i<n;i++){ prf[i] = min(prf[i],c[i]); s[i] = prf[i]; } } else if (sub3){ } return s; }
#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...