답안 #1053302

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1053302 2024-08-11T10:23:41 Z tolbi 사탕 분배 (IOI21_candies) C++17
0 / 100
77 ms 13560 KB
#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define tol(bi) ((1LL)<<((int)(bi)))
template<typename T> vector<int32_t> normalize(vector<T> v){
	vector<int32_t> ret(v.size());
	for (int i = 0; i < v.size(); ++i)
	{
		ret[i]=v[i];
	}
	return ret;
}
vector<int32_t> distribute_candies(vector<int32_t> c, vector<int32_t> l, vector<int32_t> r, vector<int32_t> v) {
	int n = c.size();
	pair<int,int> pn[n];
	for (int i = 0; i < n; i++){
		pn[i]={c[i],i};
	}
	sort(pn,pn+n);
	int ind = 0;
	int mav = 0;
	int miv = 0;
	vector<int> ans(n,-1);
	for (int i = l.size()-1; i >= 0; i--){
		int val = v[i];
		if (val<0){
			miv-=val;
		}
		else {
			mav+=val;
		}
		while (ind<n){
			if (mav+miv>=pn[ind].first){
				if (val<0) ans[pn[ind].second]=mav;
				else ans[pn[ind].second]=pn[ind].first-miv;
				ind++;
			}
			else break;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		if (ans[i]==-1) ans[i]=mav;
	}
	return normalize(ans);
}

Compilation message

candies.cpp: In instantiation of 'std::vector<int> normalize(std::vector<_Tp>) [with T = long long int]':
candies.cpp:46:22:   required from here
candies.cpp:8:20: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |  for (int i = 0; i < v.size(); ++i)
      |                  ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 77 ms 13560 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -