Submission #00063


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include<bits/stdc++.h>
using namespace std;
int dfs(int b,int a,int c);
int s[393];
int l[393];
int p[393];
int w[393];
int sum;
int n;
int end;
int m;
int use[393];
int main(){
cin >> n;
for(int i=0;i<n;i++){
cin >> s[i] >> l[i] >> p[i];
use[i]=0;
}
cin >> m;
for(int i=0;i<m;i++){
cin >> w[i];
}
int ans[m];
for(int i=0;i<m;i++){
sum=0;
end=0;
dfs(0,w[i],sum);
ans[i]=end;
}
int f=0;
for(int i=0;i<m;i++){
if(ans[i]==0){
f=1;
}
}
if(f==1){
cout << "-1" << endl;
}else{
for(int i=0;i<m;i++){
cout << ans[i] << endl;
}
}
return 0;
}
int dfs(int b,int a,int c){
if(end<c){
end=c;
}
if(b==n) return 0;
if(a>=l[b]&&use[b]==0){
dfs(b+1,a-s[b],sum+=p[b]); p[b]=0;
dfs(b+1,a,sum);
}
return 0;
}

ステータス

項目 データ
問題 0004 - VOCAL ANDROID
ユーザー名 P_ei1623
投稿日時 2016-08-12 10:50:16
言語 C++11
状態 Compile Error
得点 0
ソースコード長 869 Byte
最大実行時間 -
最大メモリ使用量

コンパイルメッセージ

./Main.cpp: In function ‘int main()’:
./Main.cpp:29:5: error: reference to ‘end’ is ambiguous
     end=0;
     ^
./Main.cpp:12:5: note: candidates are: int end
 int end;
     ^
In file included from /usr/local/gcc-5.1.0/include/c++/5.1.0/x86_64-unknown-linux-gnu/bits/stdc++.h:94:0,
                 from ./Main.cpp:1:
/usr/local/gcc-5.1.0/include/c++/5.1.0/valarray:1226:5: note:                 template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)
     end(const valarray<_Tp>& __va)
     ^
/usr/local/gcc-5.1.0/include/c++/5.1.0/valarray:1216:5: note:                 template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)
     end(valarray<_Tp>& __va)
     ^
In file included from /usr/local/gcc-5.1.0/include/c++/5.1.0/string:51:0,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/locale_classes.h:40,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/ios_base.h:41,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/ios:42,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/istream:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/sstream:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/complex:45,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/ccomplex:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/x86_64-unknown-linux-gnu/bits/stdc++.h:52,
                 from ./Main.cpp:1:
/usr/local/gcc-5.1.0/include/c++/5.1.0/bits/range_access.h:97:5: note:                 template<class _Tp, long unsigned int _Nm> _Tp* std::end(_Tp (&)[_Nm])
     end(_Tp (&__arr)[_Nm])
     ^
/usr/local/gcc-5.1.0/include/c++/5.1.0/bits/range_access.h:78:5: note:                 template<class _Container> decltype (__cont.end()) std::end(const _Container&)
     end(const _Container& __cont) -> decltype(__cont.end())
     ^
/usr/local/gcc-5.1.0/include/c++/5.1.0/bits/range_access.h:68:5: note:                 template<class _Container> decltype (__cont.end()) std::end(_Container&)
     end(_Container& __cont) -> decltype(__cont.end())
     ^
In file included from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/range_access.h:36:0,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/string:51,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/locale_classes.h:40,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/ios_base.h:41,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/ios:42,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/istream:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/sstream:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/complex:45,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/ccomplex:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/x86_64-unknown-linux-gnu/bits/stdc++.h:52,
                 from ./Main.cpp:1:
/usr/local/gcc-5.1.0/include/c++/5.1.0/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^
./Main.cpp:31:12: error: reference to ‘end’ is ambiguous
     ans[i]=end;
            ^
./Main.cpp:12:5: note: candidates are: int end
 int end;
     ^
In file included from /usr/local/gcc-5.1.0/include/c++/5.1.0/x86_64-unknown-linux-gnu/bits/stdc++.h:94:0,
                 from ./Main.cpp:1:
/usr/local/gcc-5.1.0/include/c++/5.1.0/valarray:1226:5: note:                 template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)
     end(const valarray<_Tp>& __va)
     ^
/usr/local/gcc-5.1.0/include/c++/5.1.0/valarray:1216:5: note:                 template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)
     end(valarray<_Tp>& __va)
     ^
In file included from /usr/local/gcc-5.1.0/include/c++/5.1.0/string:51:0,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/locale_classes.h:40,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/ios_base.h:41,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/ios:42,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/istream:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/sstream:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/complex:45,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/ccomplex:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/x86_64-unknown-linux-gnu/bits/stdc++.h:52,
                 from ./Main.cpp:1:
/usr/local/gcc-5.1.0/include/c++/5.1.0/bits/range_access.h:97:5: note:                 template<class _Tp, long unsigned int _Nm> _Tp* std::end(_Tp (&)[_Nm])
     end(_Tp (&__arr)[_Nm])
     ^
/usr/local/gcc-5.1.0/include/c++/5.1.0/bits/range_access.h:78:5: note:                 template<class _Container> decltype (__cont.end()) std::end(const _Container&)
     end(const _Container& __cont) -> decltype(__cont.end())
     ^
/usr/local/gcc-5.1.0/include/c++/5.1.0/bits/range_access.h:68:5: note:                 template<class _Container> decltype (__cont.end()) std::end(_Container&)
     end(_Container& __cont) -> decltype(__cont.end())
     ^
In file included from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/range_access.h:36:0,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/string:51,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/locale_classes.h:40,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/ios_base.h:41,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/ios:42,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/istream:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/sstream:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/complex:45,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/ccomplex:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/x86_64-unknown-linux-gnu/bits/stdc++.h:52,
                 from ./Main.cpp:1:
/usr/local/gcc-5.1.0/include/c++/5.1.0/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^
./Main.cpp: In function ‘int dfs(int, int, int)’:
./Main.cpp:50:6: error: reference to ‘end’ is ambiguous
   if(end<c){
      ^
./Main.cpp:12:5: note: candidates are: int end
 int end;
     ^
In file included from /usr/local/gcc-5.1.0/include/c++/5.1.0/x86_64-unknown-linux-gnu/bits/stdc++.h:94:0,
                 from ./Main.cpp:1:
/usr/local/gcc-5.1.0/include/c++/5.1.0/valarray:1226:5: note:                 template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)
     end(const valarray<_Tp>& __va)
     ^
/usr/local/gcc-5.1.0/include/c++/5.1.0/valarray:1216:5: note:                 template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)
     end(valarray<_Tp>& __va)
     ^
In file included from /usr/local/gcc-5.1.0/include/c++/5.1.0/string:51:0,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/locale_classes.h:40,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/ios_base.h:41,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/ios:42,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/istream:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/sstream:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/complex:45,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/ccomplex:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/x86_64-unknown-linux-gnu/bits/stdc++.h:52,
                 from ./Main.cpp:1:
/usr/local/gcc-5.1.0/include/c++/5.1.0/bits/range_access.h:97:5: note:                 template<class _Tp, long unsigned int _Nm> _Tp* std::end(_Tp (&)[_Nm])
     end(_Tp (&__arr)[_Nm])
     ^
/usr/local/gcc-5.1.0/include/c++/5.1.0/bits/range_access.h:78:5: note:                 template<class _Container> decltype (__cont.end()) std::end(const _Container&)
     end(const _Container& __cont) -> decltype(__cont.end())
     ^
/usr/local/gcc-5.1.0/include/c++/5.1.0/bits/range_access.h:68:5: note:                 template<class _Container> decltype (__cont.end()) std::end(_Container&)
     end(_Container& __cont) -> decltype(__cont.end())
     ^
In file included from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/range_access.h:36:0,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/string:51,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/locale_classes.h:40,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/ios_base.h:41,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/ios:42,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/istream:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/sstream:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/complex:45,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/ccomplex:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/x86_64-unknown-linux-gnu/bits/stdc++.h:52,
                 from ./Main.cpp:1:
/usr/local/gcc-5.1.0/include/c++/5.1.0/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^
./Main.cpp:51:5: error: reference to ‘end’ is ambiguous
     end=c;
     ^
./Main.cpp:12:5: note: candidates are: int end
 int end;
     ^
In file included from /usr/local/gcc-5.1.0/include/c++/5.1.0/x86_64-unknown-linux-gnu/bits/stdc++.h:94:0,
                 from ./Main.cpp:1:
/usr/local/gcc-5.1.0/include/c++/5.1.0/valarray:1226:5: note:                 template<class _Tp> const _Tp* std::end(const std::valarray<_Tp>&)
     end(const valarray<_Tp>& __va)
     ^
/usr/local/gcc-5.1.0/include/c++/5.1.0/valarray:1216:5: note:                 template<class _Tp> _Tp* std::end(std::valarray<_Tp>&)
     end(valarray<_Tp>& __va)
     ^
In file included from /usr/local/gcc-5.1.0/include/c++/5.1.0/string:51:0,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/locale_classes.h:40,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/ios_base.h:41,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/ios:42,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/istream:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/sstream:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/complex:45,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/ccomplex:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/x86_64-unknown-linux-gnu/bits/stdc++.h:52,
                 from ./Main.cpp:1:
/usr/local/gcc-5.1.0/include/c++/5.1.0/bits/range_access.h:97:5: note:                 template<class _Tp, long unsigned int _Nm> _Tp* std::end(_Tp (&)[_Nm])
     end(_Tp (&__arr)[_Nm])
     ^
/usr/local/gcc-5.1.0/include/c++/5.1.0/bits/range_access.h:78:5: note:                 template<class _Container> decltype (__cont.end()) std::end(const _Container&)
     end(const _Container& __cont) -> decltype(__cont.end())
     ^
/usr/local/gcc-5.1.0/include/c++/5.1.0/bits/range_access.h:68:5: note:                 template<class _Container> decltype (__cont.end()) std::end(_Container&)
     end(_Container& __cont) -> decltype(__cont.end())
     ^
In file included from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/range_access.h:36:0,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/string:51,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/locale_classes.h:40,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/bits/ios_base.h:41,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/ios:42,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/istream:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/sstream:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/complex:45,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/ccomplex:38,
                 from /usr/local/gcc-5.1.0/include/c++/5.1.0/x86_64-unknown-linux-gnu/bits/stdc++.h:52,
                 from ./Main.cpp:1:
/usr/local/gcc-5.1.0/include/c++/5.1.0/initializer_list:99:5: note:                 template<class _Tp> constexpr const _Tp* std::end(std::initializer_list<_Tp>)
     end(initializer_list<_Tp> __ils) noexcept
     ^

セット

セット 得点 Cases

テストケース

ファイル名 状態 実行時間 メモリ使用量 #