Submission #485666

# Submission time Handle Problem Language Result Execution time Memory
485666 2021-11-08T23:18:12 Z antontsiorvas Distributing Candies (IOI21_candies) C++17
Compilation error
0 ms 0 KB
#include "candies.h"

#include <bits/stdc++.h>
#include <vector>

const int root = 450; 
 
int buck[500]; 

std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l,
                                    std::vector<int> r, std::vector<int> v) {
    int n = c.size(), q = l.size();
    std::vector<int> s(n);
    for(int i=0; i<q; i++){
    	int sb = l[i]/root, lb = r[i]/root;
    	int esb = (sb + 1)*root - 1, slb = lb*root;
    	if(sb == lb){
    		for(int j=l[i]; j<=r[i]; j++){
    			if(v[i] > 0) s[j] = min(c[j], s[j] + v[i]);
    			else s[j] = max(0,s[j] + v[i]);
			}
			continue;
		}
    	for(int j=l[i]; j<=esb; j++){
    		if(v[i] > 0) s[j] = min(c[j], s[j] + v[i]);
    		else s[j] = max(0,s[j] + v[i]);
		}
		for(int j=sb+1; j<=lb-1; j++){
			if(v[i] > 0) buck[j] = min(c[j], buck[j] + v[i]);
    		else buck[j] = max(0,buck[j] + v[i]);
		}
		for(int j=slb; j<=r[i]; j++){
			if(v[i] > 0) s[j] = min(c[j], s[j] + v[i]);
    		else s[j] = max(0,s[j] + v[i]);
		}
	}
	for(int i=0; i<n; i++){
		s[i] = min(c[i], s[i] + buck[i/root]);
	}
    return s;
}

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:19:28: error: 'min' was not declared in this scope; did you mean 'std::min'?
   19 |        if(v[i] > 0) s[j] = min(c[j], s[j] + v[i]);
      |                            ^~~
      |                            std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from candies.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
candies.cpp:20:20: error: 'max' was not declared in this scope; did you mean 'std::max'?
   20 |        else s[j] = max(0,s[j] + v[i]);
      |                    ^~~
      |                    std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from candies.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
candies.cpp:25:27: error: 'min' was not declared in this scope; did you mean 'std::min'?
   25 |       if(v[i] > 0) s[j] = min(c[j], s[j] + v[i]);
      |                           ^~~
      |                           std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from candies.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
candies.cpp:26:19: error: 'max' was not declared in this scope; did you mean 'std::max'?
   26 |       else s[j] = max(0,s[j] + v[i]);
      |                   ^~~
      |                   std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from candies.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
candies.cpp:29:27: error: 'min' was not declared in this scope; did you mean 'std::min'?
   29 |    if(v[i] > 0) buck[j] = min(c[j], buck[j] + v[i]);
      |                           ^~~
      |                           std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from candies.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
candies.cpp:30:22: error: 'max' was not declared in this scope; did you mean 'std::max'?
   30 |       else buck[j] = max(0,buck[j] + v[i]);
      |                      ^~~
      |                      std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from candies.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
candies.cpp:33:24: error: 'min' was not declared in this scope; did you mean 'std::min'?
   33 |    if(v[i] > 0) s[j] = min(c[j], s[j] + v[i]);
      |                        ^~~
      |                        std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from candies.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
candies.cpp:34:19: error: 'max' was not declared in this scope; did you mean 'std::max'?
   34 |       else s[j] = max(0,s[j] + v[i]);
      |                   ^~~
      |                   std::max
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from candies.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: 'std::max' declared here
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
candies.cpp:38:10: error: 'min' was not declared in this scope; did you mean 'std::min'?
   38 |   s[i] = min(c[i], s[i] + buck[i/root]);
      |          ^~~
      |          std::min
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from candies.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: 'std::min' declared here
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~