Submission #1059494

#TimeUsernameProblemLanguageResultExecution timeMemory
1059494pccDistributing Candies (IOI21_candies)C++17
11 / 100
73 ms13652 KiB
#include "candies.h" #include <vector> #include <bits/stdc++.h> using namespace std; #define pii pair<int,int> #define fs first #define sc second #define ll long long int N,Q; std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l, std::vector<int> r, std::vector<int> v) { N = c.size(); Q = v.size(); if(N*Q<=1e7){ vector<int> ans(N,0); 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(ans[j]+v[i],0); } } return ans; } else if(*min_element(v.begin(),v.end())>=0){ vector<ll> dif(N+1,0); for(int i = 0;i<Q;i++){ dif[l[i]] += v[i]; dif[r[i]+1] -= v[i]; } for(int i = 1;i<dif.size();i++)dif[i] += dif[i-1]; vector<int> ans(N); for(int i = 0;i<N;i++)ans[i] = min(1ll*c[i],dif[i]); return ans; } assert(false); }

Compilation message (stderr)

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:34:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   for(int i = 1;i<dif.size();i++)dif[i] += dif[i-1];
      |                 ~^~~~~~~~~~~
#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...