답안 #544057

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
544057 2022-03-31T22:50:31 Z brunnorezendes 사탕 분배 (IOI21_candies) C++17
0 / 100
167 ms 19884 KB
#include "candies.h"
#include <bits/stdc++.h>
#define s second
#define f first
#define maxi 10e9 + 1

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, aux;
	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];
			aux = sum;
			sum = max(0, sum);
			sum = min(c[0], sum);
			v[ind] += sum-aux;
		}
		else{
			if(type == 2) sum-=v[ind];
			else sum+=v[ind];
		}
		sum %= (int)maxi;
	}
	return val;
}

Compilation message

candies.cpp: In function 'vi distribute_candies(vi, vi, vi, vi)':
candies.cpp:27: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]
   27 |  for(i=0;i<sweep.size();i++){
      |          ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 167 ms 19884 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 304 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -