Submission #543994

# Submission time Handle Problem Language Result Execution time Memory
543994 2022-03-31T19:04:21 Z brunnorezendes Distributing Candies (IOI21_candies) C++17
0 / 100
177 ms 19796 KB
#include "candies.h"
#include <bits/stdc++.h>
#define s second
#define f first

using namespace std;

typedef vector <int> vi;
typedef pair<pair<int,int> , int> iii;
typedef vector<iii> viii;


vi distribute_candies(vi c, vi l, vi r, vi v){
	int q = l.size(), n = c.size(), i, flag=0, type, ind, sum=0;
	vi val(n, 0);
	viii sweep;
	for(i=0;i<q;i++){
		if(v[i]<0) flag=1;
		sweep.push_back({{l[i], 0}, i});
		sweep.push_back({{r[i], 2}, i});
	}
	for(i=0;i<n;i++){
		sweep.push_back({{i, 1}, i});
	}
	sort(sweep.begin(), sweep.end());
	for(i=0;i<sweep.size();i++){
		ind = sweep[i].s;
		type = sweep[i].f.s;
		if(type == 1){
			val[ind] = min(c[ind], sum);
		}
		else if(flag){
			if(type == 2) sum-=v[ind];
			else sum+=v[ind];
			sum = max(0, sum);
			sum = min(c[0], sum);
		}
		else{
			if(type == 2) sum-=v[ind];
			else sum+=v[ind];
		}
	}
	return val;
}

Compilation message

candies.cpp: In function 'vi distribute_candies(vi, vi, vi, vi)':
candies.cpp:26:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<std::pair<int, int>, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |  for(i=0;i<sweep.size();i++){
      |          ~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 177 ms 19796 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -