제출 #1169456

#제출 시각아이디문제언어결과실행 시간메모리
1169456Szymon_PilipczukJelly Flavours (IOI20_jelly)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int find_maximum_unique(int x,int y,vector<int> a,vector<int> b) { int n = a.size(); vector<pair<int,int>> mc(n); for(int i = 0;i<n;i++) { mc[i] = {a[i],b[i]}; } vector<pair<int,int>> mc(n); sort(mc.begin(),mc.end()); int dp[n][x+1]; for(int i = 0;i<n;i++) { for(int j = 0;j<=x;j++) { if(i == 0) { if(j >= mc[i].first) { dp[i][j] = 0; } else { dp[i][j] = mc[i].second; } } else { dp[i][j] = dp[i-1][j] + mc[i].second; if(j >= mc[i].first) { dp[i][j] = min(dp[i][j],dp[i-1][j-mc[i].first]); } } } } int ans = 0; for(int i =0 ;i<n;i++) { int cy = y; cy -= dp[i][x]; if(cy >= 0) { vector<int> r; for(int j = i+1;j<n;j++) { r.push_back(mc[j].second); } sort(r.begin(),r.end()); int cans = 0; for(int j = 0;j<r.size();j++) { if(cy >= r[j]) { cy-=r[j]; cans++; } } ans = max(ans,cans+i+1); } } int cy = y; vector<int> r; for(int j = 0;j<n;j++) { r.push_back(mc[j].second); } sort(r.begin(),r.end()); int cans = 0; for(int j = 0;j<r.size();j++) { if(cy >= r[j]) { cy-=r[j]; cans++; } } ans = max(ans,cans); return ans; }

컴파일 시 표준 에러 (stderr) 메시지

jelly.cpp: In function 'int find_maximum_unique(int, int, std::vector<int>, std::vector<int>)':
jelly.cpp:11:27: error: redeclaration of 'std::vector<std::pair<int, int> > mc'
   11 |     vector<pair<int,int>> mc(n);
      |                           ^~
jelly.cpp:6:27: note: 'std::vector<std::pair<int, int> > mc' previously declared here
    6 |     vector<pair<int,int>> mc(n);
      |                           ^~