제출 #721607

#제출 시각아이디문제언어결과실행 시간메모리
721607ovidiush11은행 (IZhO14_bank)C++14
19 / 100
5 ms308 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e3+5; bool check(vector<int> x,vector<int> y,int s,int k,vector<int> left,vector<int> right) { if(s < 0)return 0; if(s == 0) { if(x.size() == 1)return 1; int suma = 0; for(int i = 0;i < x.size()/2;i++)suma += x[i]; vector<int> tp; for(int i = 0;i < x.size()/2;i++)tp.push_back(x[i]); if(check(tp,left,suma,0,vector<int>(),vector<int>())) { tp.clear(); suma = 0; for(int i = k;i < y.size();i++)right.push_back(y[i]); for(int i = x.size()/2;i < x.size();i++)suma += x[i]; for(int i = x.size()/2;i < x.size();i++)tp.push_back(x[i]); if(check(tp,right,suma,0,vector<int>(),vector<int>()))return 1; } return 0; } for(int i = k;i < y.size();i++) { if(i > k && y[i] == y[i-1]){right.push_back(y[i]);continue;} left.push_back(y[i]); if(check(x,y,s-y[i],i+1,left,right))return 1; left.pop_back(); right.push_back(y[i]); } return 0; } int n,m; vector<int> v,a,b; bool sum(int s,int k) { if(s < 0)return 0; if(s == 0) { int suma = 0; for(int i = 0;i < a.size()/2;i++)suma += a[i]; if(check(a,v,suma,0,vector<int>(),vector<int>()))return 1; return 0; } for(int i = k;i < m;i++) { if(i > k && b[i] == b[i-1])continue; v.push_back(b[i]); if(sum(s-b[i],i+1))return 1; v.pop_back(); } return 0; } int main() { cin>>n>>m; a.resize(n); b.resize(m); for(int i = 0;i < n;i++)cin>>a[i]; for(int i = 0;i < m;i++)cin>>b[i]; sort(a.begin(),a.end()); sort(b.begin(),b.end()); a.push_back(0); int s = 0; for(int i = 0;i < n;i++)s += a[i]; if(sum(s,0))cout<<"YES"<<endl; else cout<<"NO"<<endl; return 0; }

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

bank.cpp: In function 'bool check(std::vector<int>, std::vector<int>, int, int, std::vector<int>, std::vector<int>)':
bank.cpp:13:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |         for(int i = 0;i < x.size()/2;i++)suma += x[i];
      |                       ~~^~~~~~~~~~~~
bank.cpp:15:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |         for(int i = 0;i < x.size()/2;i++)tp.push_back(x[i]);
      |                       ~~^~~~~~~~~~~~
bank.cpp:20:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |             for(int i = k;i < y.size();i++)right.push_back(y[i]);
      |                           ~~^~~~~~~~~~
bank.cpp:21:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |             for(int i = x.size()/2;i < x.size();i++)suma += x[i];
      |                                    ~~^~~~~~~~~~
bank.cpp:22:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |             for(int i = x.size()/2;i < x.size();i++)tp.push_back(x[i]);
      |                                    ~~^~~~~~~~~~
bank.cpp:27:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i = k;i < y.size();i++)
      |                   ~~^~~~~~~~~~
bank.cpp: In function 'bool sum(int, int)':
bank.cpp:47:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |         for(int i = 0;i < a.size()/2;i++)suma += a[i];
      |                       ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...