답안 #530447

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
530447 2022-02-25T11:29:55 Z Icebear16 사탕 분배 (IOI21_candies) C++17
컴파일 오류
0 ms 0 KB
#include "candies.h"
#include <vector>

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();
    int q=l.size();
    std::vector<int> s(n,0);
    bool flag=true;
    for(int i=0;i<q;i++){
    	if(v[i]<0){
    		flag=false;
    		break;
		}
	}
	if(flag==false){
		for(int j=0;j<q;j++){
			for(int i=l[j];i<=r[j];i++){
				if(v[j]>=0){
					if(c[i]>(s[i]+v[j])) s[i]+=v[j];
					else s[i]=c[i];
				}else{
					if((s[i]+v[j])<0) s[i]=0;
					else s[i]+=v[j];
				}
			}
		}
	}else{
		s.push_back(0);
		int h,k;
		for(int j=0;j<q;j++){
			h=l[j];
			s[h]+=v[j];
			k=r[j+1];
			s[k]-=v[j];
		}
		for(int i=1;i<=n;i++){
			s[i]+=s[i-1];
		}
		reverse(s.begin(),s.end());
		s.pop_back();
		reverse(s.begin(),s.end());
	}
    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:39:3: error: 'reverse' was not declared in this scope
   39 |   reverse(s.begin(),s.end());
      |   ^~~~~~~