submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s516664909
p03732
C++
#include <iostream> #include <string> #include <algorithm> #include <cmath> #include <math.h> #include <vector> #include <stack> #include <queue> #include <map> #include <set> #include <limits.h> using namespace std; typedef long long ll; #define INF LLONG_MAX/3 #define inf INT_MAX/3 #define MOD 1000000007 #define rep(i,n) for(int i=0;i<(n);i++) int gcd(int a, int b) { if (b == 0)return a; return gcd(b, a%b); } int lcm(int a, int b) { return a / gcd(a, b)*b; } bool prime(int p) { for (int i = 2;i <= sqrt(p);i++) { if (p%i == 0)return false; } return true; } int modpow(int a, int b) { if (b == 0)return 1; if (b == 1)return a % MOD; if (b % 2)return modpow(a, b - 1)* #include <limits.a%MOD; else return modpow(a, b / 2)*modpow(a, b / 2) % MOD; } int comb(int a, int b) { if (b == 0 || a == b)return 1; if (b == 1)return a % MOD; return (comb(a - 1, b - 1) + comb(a - 1, b)) % MOD; } // Library End ! int N,W,w[100],v[100]; int dp[101][400][101]; int main() { cin>>N>>W; rep(i,n)cin>>w[i]>>v[i]; for(int i=1;i<n;i++){ for(int j=0;j<=300;j++){ for(int k=0;k<n;k++){ //あーあーあーあーあーあーあーあーあーあーあーあーあー } } } return 0; }
a.cc:35:24: error: missing terminating > character 35 | #include <limits.a%MOD; | ^ a.cc:35:10: fatal error: limits.a%1000000007;: No such file or directory 35 | #include <limits.a%MOD; | ^ compilation terminated.
s525670274
p03732
C++
#include <bits/stdc++.h> using namespace std; #define EACH(i,a) for (auto& i : a) #define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i) #define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) RFOR(i,0,n) #define ALL(a) (a).begin(),(a).end() #define debug(x) cerr << #x << ":" << x << endl; #define OK(ok) cout << (ok ? "Yes" : "No") << endl; typedef long long ll; void CINT(){} template <class Head,class... Tail> void CINT(Head&& head,Tail&&... tail) { cin >> head; CINT(move(tail)...); } #define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__) #define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__) #define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__) const int INF = 1e9 + 1; const int MOD = 1e9 + 7; const int MAX_N = 575; // dp[見てるとこ][重さ] ll dp[MAX_N][MAX_N * MAX_Nx]; int main() { cin.tie(0); ios::sync_with_stdio(false); CIN(N, W); vector< ll > w(N); vector< ll > v(N); REP(i, N) { cin >> w[i] >> v[i]; } vector< ll > diff_w(N); REP(i, N) { diff_w[i] = w[i] - w[0]; } ll sm = 0; // 見ているとこ REP(i, N) { RREP(j, N) { if (j > i) { // iまでで作るので continue; } RREP(k, sm + 1) { dp[j + 1][k + diff_w[i]] = max(dp[j + 1][k + diff_w[i]], dp[j][k] + v[i]); } } sm += diff_w[i]; } ll ans = 0ll; REP(i, N + 1) { REP(j, 3 * N) { if (w[0] * i + j > W) { // 重さがWを超えた時には入れない continue; } debug(dp[i][j]); ans = max(ans, dp[i][j]); } } cout << ans << endl; return 0; }
a.cc:29:22: error: 'MAX_Nx' was not declared in this scope; did you mean 'MAX_N'? 29 | ll dp[MAX_N][MAX_N * MAX_Nx]; | ^~~~~~ | MAX_N a.cc: In function 'int main()': a.cc:56:9: error: 'dp' was not declared in this scope; did you mean 'dup'? 56 | dp[j + 1][k + diff_w[i]] = max(dp[j + 1][k + diff_w[i]], | ^~ | dup a.cc:70:13: error: 'dp' was not declared in this scope; did you mean 'dup'? 70 | debug(dp[i][j]); | ^~ a.cc:11:39: note: in definition of macro 'debug' 11 | #define debug(x) cerr << #x << ":" << x << endl; | ^
s562396440
p03732
C++
#include<iostream> #include<algorithm> using namespace std; int main() { int n, W, v, w; cin >> n >> W; int *dp = new int[W+2]; memset(dp, 0, sizeof(int)*(W+2)); while(n--){ cin >> w >> v; for (int i = W; i >= w; --i) { if(i >= w) dp[i] = max(dp[i - w] + v, dp[i]); else dp[i] = dp[i-1]; } } cout << dp[W]; delete[] dp; }
a.cc: In function 'int main()': a.cc:8:9: error: 'memset' was not declared in this scope 8 | memset(dp, 0, sizeof(int)*(W+2)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<algorithm> +++ |+#include <cstring> 3 | using namespace std;
s383964939
p03732
C++
#include<stdio.h> #include<algorithm> using namespace std; int main() { memset(dp, 0, sizeof(int)*(W+2)); }
a.cc: In function 'int main()': a.cc:6:16: error: 'dp' was not declared in this scope 6 | memset(dp, 0, sizeof(int)*(W+2)); | ^~ a.cc:6:36: error: 'W' was not declared in this scope 6 | memset(dp, 0, sizeof(int)*(W+2)); | ^ a.cc:6:9: error: 'memset' was not declared in this scope 6 | memset(dp, 0, sizeof(int)*(W+2)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<algorithm> +++ |+#include <cstring> 3 | using namespace std;
s100760259
p03732
C++
#include<stdio.h> #include<algorithm> using namespace std; int main() { memset(dp, 0, sizeof(int)*(W+2)); }
a.cc: In function 'int main()': a.cc:5:16: error: 'dp' was not declared in this scope 5 | memset(dp, 0, sizeof(int)*(W+2)); | ^~ a.cc:5:36: error: 'W' was not declared in this scope 5 | memset(dp, 0, sizeof(int)*(W+2)); | ^ a.cc:5:9: error: 'memset' was not declared in this scope 5 | memset(dp, 0, sizeof(int)*(W+2)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<algorithm> +++ |+#include <cstring> 3 | using namespace std;
s033706935
p03732
C++
#include<stdio.h> #include<algorithm> using namespace std; int main() { int n, W, v, w; scanf("%d %d", &n, &W); int *dp = new int[W+2]; memset(dp, 0, sizeof(int)*(W+2)); while(n--){ scanf("%d %d", &w, &v); for (int i = W; i >= w; --i) { if(i >= w) dp[i] = max(dp[i - w] + v, dp[i]); else dp[i] = dp[i-1]; } } printf("%d\n", dp[W]); delete[] dp; }
a.cc: In function 'int main()': a.cc:8:9: error: 'memset' was not declared in this scope 8 | memset(dp, 0, sizeof(int)*(W+2)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<algorithm> +++ |+#include <cstring> 3 | using namespace std;
s702583960
p03732
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; long long N, W; long long nap(long long, long long, vector <long long>, vector <long long>, vector <vector <long long> >&); int main(){ cin>>N>>W; vector <long long>w(N); vector <long long>v(N); vector <vector <long long> >dp(N+1, vector <long long>(W+1, -1)); for(int i = 0 ; i < N ; i++){ cin>>w[i]>>v[i]; } cout<<nap(0, W, w, v, dp)<<endl; return 0; } long long nap(long long i, long long j, vector <long long>w, vector <long long>v, vector <vector <long long> >&dp) { if (dp[i][j] != -1) return dp[i][j]; long long ans = 0; if (i == N) ans = 0; else if (j < w[i]) { ans = nap(i + 1, j, w, v, dp); } else { ans = max(nap(i + 1, j, w, v, dp), (nap(i + 1, j - w[i], w, v, dp) + v[i])); } dp[i][j] = ans return ans; }
a.cc: In function 'long long int nap(long long int, long long int, std::vector<long long int>, std::vector<long long int>, std::vector<std::vector<long long int> >&)': a.cc:33:19: error: expected ';' before 'return' 33 | dp[i][j] = ans | ^ | ; 34 | return ans; | ~~~~~~ a.cc:33:14: warning: control reaches end of non-void function [-Wreturn-type] 33 | dp[i][j] = ans
s219147988
p03732
C++
#include<bits/stdc++.h> using namespace std; int main(){ long long N, W; cin >> N >> W; vector<long long> w(N); vector<long long> v(N); for(long long i = 0; i < N; i++) cin >> w[i] >> v[i]; vector<long long> a(1, 0LL); vector<long long> b(1, 0LL); vector<long long> c(1, 0LL); vector<long long> d(1, 0LL); a.push_back(v[0]); for(long long i = 1; i < N; i++){ if(w[i] == w[0]) a.push_back(v[i]); else if(w[i] == w[0] + 1LL) b.push_back(v[i]); else if(w[i] == w[0] + 2LL) c.push_back(v[i]); else d.push_back(v[i]); } sort(a.begin() + 1, a.end(), greater<long long>); sort(b.begin() + 1, b.end(), greater<long long>); sort(c.begin() + 1, c.end(), greater<long long>); sort(d.begin() + 1, d.end(), greater<long long>); for(long long i = 1; i < (long long)a.size(); i++) a[i] += a[i - 1]; for(long long i = 1; i < (long long)b.size(); i++) b[i] += b[i - 1]; for(long long i = 1; i < (long long)c.size(); i++) c[i] += c[i - 1]; for(long long i = 1; i < (long long)d.size(); i++) d[i] += d[i - 1]; long long ans = 0LL; //全探索 for(long long i = 0; i < (long long)a.size(); i++){ for(long long j = 0; j < (long long)b.size(); j++){ for(long long k = 0; k < (long long)c.size(); k++){ for(long long l = 0; l < (long long)d.size(); l++){ long long tmp_w = i * w[0] + j * (w[0] + 1LL) + k * (w[0] + 2LL) + l * (w[0] + 3LL); //cout << i << " " << j << " " << k << " " << l << endl; if(tmp_w > W) continue; long long tmp_v = a[i] + b[j] + c[k] + d[l]; ans = max(ans, tmp_v); //cout << i << " " << j << " " << k << " " << l << " " << tmp_w << " " << tmp_v << endl; } } } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:22:52: error: expected primary-expression before ')' token 22 | sort(a.begin() + 1, a.end(), greater<long long>); | ^ a.cc:23:52: error: expected primary-expression before ')' token 23 | sort(b.begin() + 1, b.end(), greater<long long>); | ^ a.cc:24:52: error: expected primary-expression before ')' token 24 | sort(c.begin() + 1, c.end(), greater<long long>); | ^ a.cc:25:52: error: expected primary-expression before ')' token 25 | sort(d.begin() + 1, d.end(), greater<long long>); | ^
s564527449
p03732
C++
//Written by Zhu Zeqi //Come on,baby //Hack,please #include<cmath> #include<math.h> #include<ctype.h> #include<algorithm> #include<bitset> #include<cassert> #include<cctype> #include<cerrno> #include<cfloat> #include<ciso646> #include<climits> #include<clocale> #include<complex> #include<csetjmp> #include<csignal> #include<cstdarg> #include<cstddef> #include<cstdio> #include<cstdlib> #include<cstring> #include<ctime> #include<cwchar> #include<cwctype> #include<deque> #include<exception> #include<fstream> #include<functional> #include<iomanip> #include<ios> #include<iosfwd> #include<iostream> #include<istream> #include<iterator> #include<limits> #include<list> #include<locale> #include<map> #include<memory> #include<new> #include<numeric> #include<ostream> #include<queue> #include<set> #include<sstream> #include<stack> #include<stdexcept> #include<streambuf> #include<string> #include<typeinfo> #include<utility> #include<valarray> #include<vector> #include<string.h> #include<stdlib.h> #include<stdio.h> #define CLR(x) memset(x,0,sizeof x) #define pb push_back #define mp make_pair #define F first #define S second #define pii pair<int,int> #define vi vector<int> #define MAX 1000000000000000000 #define MOD 1000000007 #define PI 3.141592653589793238462 #define INF 0x3F3F3F3F typedef long long ll; //orz yht using namespace std; string i_s(int x){ if(x==0) return "0"; string ret=""; while(x){ ret=ret+(char)(x%10+'0'); x/=10; } reverse(ret.begin(),ret.end()); return ret; } string add(string a,string b){ if(a=="") a="0"; if(b=="") b="0"; if(a.length()<b.length()) swap(a,b); while(b.length()<a.length()){ b='0'+b; } for(int i=0;i<a.length();i++){ a[i]=a[i]+(b[i]-'0'); } bool big=false; for(int i=a.length()-1;i>=0;i--){ if(big){ a[i]++; } big=false; if(a[i]>'9'){ a[i]=a[i]-10; big=true; } } if(big) a='1'+a; return a; } string mul(string a,string b){ vector<int> va,vb; if(a=="0" || b=="0") return "0"; string ans; for(int i=0;i<a.length();i++){ va.push_back(a[i]-'0'); } for(int i=0;i<b.length();i++){ vb.push_back(b[i]-'0'); } reverse(va.begin(),va.end()); reverse(vb.begin(),vb.end()); vector<int> res; res.clear(); res.resize(1005); for(int i=0;i<a.length();i++){ for(int j=0;j<b.length();j++){ res[i+j]+=(va[i]*vb[j]); } } for(int i=0;i<1005;i++){ if(res[i]>9){ res[i+1]+=(res[i]/10); res[i]%=10; } } for(int i=0;i<1005;i++){ ans+=(res[i]+'0'); } reverse(ans.begin(),ans.end()); int k=0; while(ans[k]=='0'){ k++; } ans=ans.substr(k); return ans; } bool is_prime(int n){ if(n<2) return false; for(int i=2;i*i<=n;i++) if(n%i==0) return false; return true; } struct good { int w,v; }g[110]; bool cmp(good a,good b) { return a.v > b.v; } good A[110],B[110],C[110],D[110]; ll swa[110],swb[110],swc[110],swd[110]; ll sva[110],svb[110],svc[110],svd[110]; int main(){ //freopen("input.in","r",stdin); //freopen("output.out","w",stdout); int n,w,i,j,k,l; int a,b,c,d; while(scanf("%d%d",&n,&w)==2) { a = b = c = d = 0; for(i=1;i<=n;i++) { scanf("%d%d",&g[i].w,&g[i].v); if(g[i].w == g[1].w) A[++a] = g[i]; if(g[i].w == g[1].w + 1) B[++b] = g[i]; if(g[i].w == g[1].w + 2) C[++c] = g[i]; if(g[i].w == g[1].w + 3) D[++d] = g[i]; } sort(A+1,A+a+1,cmp); sort(B+1,B+b+1,cmp); sort(C+1,C+c+1,cmp); sort(D+1,D+d+1,cmp); swa[0] = swb[0] = swc[0] = swd[0] = 0; sva[0] = svb[0] = svc[0] = svd[0] = 0; for(i=1;i<=a;i++) { swa[i] = swa[i-1] + A[i].w; sva[i] = sva[i-1] + A[i].v; } for(i=1;i<=b;i++) { swb[i] = swb[i-1] + B[i].w; svb[i] = svb[i-1] + B[i].v; } for(i=1;i<=c;i++) { swc[i] = swc[i-1] + C[i].w; svc[i] = svc[i-1] + C[i].v; } for(i=1;i<=d;i++) { swd[i] = swd[i-1] + D[i].w; svd[i] = svd[i-1] + D[i].v; } int sumv = 0; int ans = 0; for(i=0;i<=a;i++) { for(j=0;j<=b;j++) { for(k=0;k<=c;k++) { for(l=0;l<=d;l++) { ll sum = swa[i] + swb[j] + swc[k] + swd[l]; if(sum <= (ll)w) { ans = max((LL)ans,sva[i]+svb[j]+svc[k]+svd[l]); } } } } } cout << ans << endl; } //system("pause"); return 0; }
a.cc: In function 'int main()': a.cc:231:40: error: 'LL' was not declared in this scope; did you mean 'll'? 231 | ans = max((LL)ans,sva[i]+svb[j]+svc[k]+svd[l]); | ^~ | ll
s213644075
p03732
C++
//Written by Zhu Zeqi //Come on,baby //Hack,please #include<cmath> #include<math.h> #include<ctype.h> #include<algorithm> #include<bitset> #include<cassert> #include<cctype> #include<cerrno> #include<cfloat> #include<ciso646> #include<climits> #include<clocale> #include<complex> #include<csetjmp> #include<csignal> #include<cstdarg> #include<cstddef> #include<cstdio> #include<cstdlib> #include<cstring> #include<ctime> #include<cwchar> #include<cwctype> #include<deque> #include<exception> #include<fstream> #include<functional> #include<iomanip> #include<ios> #include<iosfwd> #include<iostream> #include<istream> #include<iterator> #include<limits> #include<list> #include<locale> #include<map> #include<memory> #include<new> #include<numeric> #include<ostream> #include<queue> #include<set> #include<sstream> #include<stack> #include<stdexcept> #include<streambuf> #include<string> #include<typeinfo> #include<utility> #include<valarray> #include<vector> #include<string.h> #include<stdlib.h> #include<stdio.h> #define CLR(x) memset(x,0,sizeof x) #define pb push_back #define mp make_pair #define F first #define S second #define pii pair<int,int> #define vi vector<int> #define MAX 1000000000000000000 #define MOD 1000000007 #define PI 3.141592653589793238462 #define INF 0x3F3F3F3F typedef long long ll; //orz yht using namespace std; string i_s(int x){ if(x==0) return "0"; string ret=""; while(x){ ret=ret+(char)(x%10+'0'); x/=10; } reverse(ret.begin(),ret.end()); return ret; } string add(string a,string b){ if(a=="") a="0"; if(b=="") b="0"; if(a.length()<b.length()) swap(a,b); while(b.length()<a.length()){ b='0'+b; } for(int i=0;i<a.length();i++){ a[i]=a[i]+(b[i]-'0'); } bool big=false; for(int i=a.length()-1;i>=0;i--){ if(big){ a[i]++; } big=false; if(a[i]>'9'){ a[i]=a[i]-10; big=true; } } if(big) a='1'+a; return a; } string mul(string a,string b){ vector<int> va,vb; if(a=="0" || b=="0") return "0"; string ans; for(int i=0;i<a.length();i++){ va.push_back(a[i]-'0'); } for(int i=0;i<b.length();i++){ vb.push_back(b[i]-'0'); } reverse(va.begin(),va.end()); reverse(vb.begin(),vb.end()); vector<int> res; res.clear(); res.resize(1005); for(int i=0;i<a.length();i++){ for(int j=0;j<b.length();j++){ res[i+j]+=(va[i]*vb[j]); } } for(int i=0;i<1005;i++){ if(res[i]>9){ res[i+1]+=(res[i]/10); res[i]%=10; } } for(int i=0;i<1005;i++){ ans+=(res[i]+'0'); } reverse(ans.begin(),ans.end()); int k=0; while(ans[k]=='0'){ k++; } ans=ans.substr(k); return ans; } bool is_prime(int n){ if(n<2) return false; for(int i=2;i*i<=n;i++) if(n%i==0) return false; return true; } struct good { int w,v; }g[110]; bool cmp(good a,good b) { return a.v > b.v; } good A[110],B[110],C[110],D[110]; ll swa[110],swb[110],swc[110],swd[110]; ll sva[110],svb[110],svc[110],svd[110]; int main(){ //freopen("input.in","r",stdin); //freopen("output.out","w",stdout); int n,w,i,j,k,l; int a,b,c,d; while(scanf("%d%d",&n,&w)==2) { a = b = c = d = 0; for(i=1;i<=n;i++) { scanf("%d%d",&g[i].w,&g[i].v); if(g[i].w == g[1].w) A[++a] = g[i]; if(g[i].w == g[1].w + 1) B[++b] = g[i]; if(g[i].w == g[1].w + 2) C[++c] = g[i]; if(g[i].w == g[1].w + 3) D[++d] = g[i]; } sort(A+1,A+a+1,cmp); sort(B+1,B+b+1,cmp); sort(C+1,C+c+1,cmp); sort(D+1,D+d+1,cmp); swa[0] = swb[0] = swc[0] = swd[0] = 0; sva[0] = svb[0] = svc[0] = svd[0] = 0; for(i=1;i<=a;i++) { swa[i] = swa[i-1] + A[i].w; sva[i] = sva[i-1] + A[i].v; } for(i=1;i<=b;i++) { swb[i] = swb[i-1] + B[i].w; svb[i] = svb[i-1] + B[i].v; } for(i=1;i<=c;i++) { swc[i] = swc[i-1] + C[i].w; svc[i] = svc[i-1] + C[i].v; } for(i=1;i<=d;i++) { swd[i] = swd[i-1] + D[i].w; svd[i] = svd[i-1] + D[i].v; } int sumv = 0; int ans = 0; for(i=0;i<=a;i++) { for(j=0;j<=b;j++) { for(k=0;k<=c;k++) { for(l=0;l<=d;l++) { LL sum = swa[i] + swb[j] + swc[k] + swd[l]; if(sum <= (LL)w) { ans = max((LL)ans,sva[i]+svb[j]+svc[k]+svd[l]); } } } } } cout << ans << endl; } //system("pause"); return 0; }
a.cc: In function 'int main()': a.cc:228:25: error: 'LL' was not declared in this scope; did you mean 'll'? 228 | LL sum = swa[i] + swb[j] + swc[k] + swd[l]; | ^~ | ll a.cc:229:28: error: 'sum' was not declared in this scope; did you mean 'sumv'? 229 | if(sum <= (LL)w) | ^~~ | sumv a.cc:229:39: error: expected ')' before 'w' 229 | if(sum <= (LL)w) | ~ ^ | ) a.cc:231:43: error: expected ')' before 'ans' 231 | ans = max((LL)ans,sva[i]+svb[j]+svc[k]+svd[l]); | ~ ^~~ | )
s023311249
p03732
C++
#include<cstdio> #include<cstring> #include<string> #include<algorithm> #include<iostream> #include<cmath> #include<cstdlib> #include<ctime> #include<map> #include<queue> #include<vector> #include<stack> #include<set> #include<cctype> #define pa pair<int,int> #define INF 0x3f3f3f3f #define inf 0x3f #define fi first #define se second #define mp make_pair #define ll long long #define ull unsigned long long #define pb push_back using namespace std; inline ll read() { long long f=1,sum=0; char c=getchar(); while (!isdigit(c)) {if (c=='-') f=-1;c=getchar();} while (isdigit(c)) {sum=sum*10+c-'0';c=getchar();} return sum*f; } const int MAXN=110; const int N=400; int f[MAXN][MAXN][N*2+10],w[MAXN],v[MAXN]; int main() { int n,W; scanf("%d%d",&n,&W); /* for (int i=1;i<=n;i++) scanf("%d%d",&w[i],&v[i]); memset(f,-1,sizeof(f)); f[0][0][0]=0; for (int i=0;i<n;i++) for (int j=0;j<=i;j++) for (int k=0;k<=3*j;k++) { if (f[i][j][k]==-1) continue; f[i+1][j][k]=max(f[i+1][j][k],f[i][j][k]); f[i+1][j+1][k+w[i+1]-w[1]]=max(f[i+1][j+1][k+w[i+1]-w[1]],f[i][j][k]+v[i+1]); }*/ for (int i=0;i<n;i++) scanf("%d%d",&w[i],&v[i]); for (int i=0;i<n;i++) for (int j=0;j<=i;j++) for (int k=0;k<=3*j;k++) { if (f[i][j][k]==-1) continue; f[i+1][j][k]=max(f[i+1][j][k],f[i][j][k]); f[i+1][j+1][k+w[i]-w[0]]=max(f[i+1][j+1][k+w[i]-w[0]],f[i][j][k]+v[i]); int ans=0; for (int i=0;i<=n;i++) for (int j=0;j<=3*i;j++) { ll k=i*w[0]+j; if (k<=W) ans=max(ans,f[n][i][j]); } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:74:2: error: expected '}' at end of input 74 | } | ^ a.cc:39:1: note: to match this '{' 39 | { | ^
s549040016
p03732
C++
#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define LL long long using namespace std; int a[105],b[105]; LL f[105][305]; int main(void) { int i,j,k,n,m,a1;LL ans=0; scanf("%d%d",&n,&m); for(i=1;i<=n;++i)scanf("%d%d",&a[i],&b[i]); a1=a[1]; for(i=1;i<=n;++i)a[i]-=a1; for(i=0;i<=n;++i) { for(j=0;j<=300;++j)f[i][j]=-0x3F3F3F3F3F3F3F3F; } f[0][0]=0; for(i=1;i<=n;++i) { for(j=i;j>=1;--j) { for(k=300;k>=a[i];--k)f[j][k]=max(f[j][k],f[j-1][k-a[i]]+b[i]); } } for(i=1;i<=n;++i) { if(m-1LL*i*a1<0)break; for(j=0;j<=min(300,m-1LL*i*a1);++j)ans=max(ans,f[i][j]); } printf("%lld\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:31:31: error: no matching function for call to 'min(int, long long int)' 31 | for(j=0;j<=min(300,m-1LL*i*a1);++j)ans=max(ans,f[i][j]); | ~~~^~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:31:31: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 31 | for(j=0;j<=min(300,m-1LL*i*a1);++j)ans=max(ans,f[i][j]); | ~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:4: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:31:31: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 31 | for(j=0;j<=min(300,m-1LL*i*a1);++j)ans=max(ans,f[i][j]); | ~~~^~~~~~~~~~~~~~~~
s623683189
p03732
C++
/* * UM. * J@B@1 iO@1 * Y@@@B@BB. 7B@B@B@ * :@B@i,B@B@O ,Z@B@B@B@Br * @B@q i@B@BS 7@B@@@O5vMB@q * 8@@B LB@B@i FB@@@BNjYjLE@B@ * ,B@B: 0@@@Z P@B@BM1JJ125JPB@B * B@BB :@B@B XB@B@Z2LuU52F2u2@B@. * :@B@ @@@B: v@B@B8uJj51F1525uUB@B7 * @B@O 0@@B. ..::ir7vvYUuU777r::. B@B@OULU2F2F151F11Y@B@S * B@B, 8B@B :ruXMB@B@B@B@B@B@B@B@B@B@@@B@B@B@B@B@B@5Jj1211F1F1F2FUJO@BB * U@B@ @B@B@B@B@B@@@B@B@B@MMqPS5JuYL7rq@B@OBB@B@B8Yu211F1515251515YGB@@ * @B@u v@@@@MSur:. LB@MvvjJuU5YU252F1F1F25251F2uX@@@ * @@@. N@BML2U2UUU12F15252525251515Jk@@B * r@B@ YB@Bju52121252515252F15251F2u5@B@ * PB@B @@@PYUF151F25151F152F2F1F15jF@@B * @@BS N@@@UJ2F25252F251525151F1F1u5@B@ * @@@7 B@B@5Yj12F152F1F1F25252515jFB@B * B@Bi M@B@O2Luu52525212F151121UY1@B@7 * O@B@: v@B@BMSuYJJuuUu2u2uujjYJJXB@B@M * 7B@B@, 1B@@@B@GPF1uujuu21PNMB@B@B@B@@ * qB@B2 i8B@B@B@B@B@@@@@B@B@B@q: @@@B * MB@B: 7SBB@B@B@B@B@Zu: @B@B * ZB@B. ,v. @B@L * LB@B, Y7 @B@Bu 7@B@ * :B@B@@B2: @@B7 @B@Z r@B@B@BP: B@BE * BB@@@B@B@B@BE r@B@B 7@B@B@B@Ou: iB@B * :uM@@B@@2. :7::::ivk@B@B@0 :5B@B@B@B@B@B@G. @B@i * BB@@@B@@ :@B@B@@@B@B@@1 .i5M@B@B@@@5 M@@2 * B@B ,@B1 L0EZZG0F7: .:, uB@MrP@M7 * 2@B@ ,O@B@B@B@B * @B@1 :@B@@@r :@@@@B@BL:,, * B@Bi :2ZS; :@B@B@B@r L@B@B@BU * @B@. @@@B@B@ vB@B@B@B5 @B@i * B@B 7B@B@B@BM OB@B@B@ ,B@B * @B@ @B@B@@@i rL7. B@BM * B@B7.: NB@@M. .@B@. * .;JEB@@@B@B@B@B@. . @B@u *@@@B@B@B@B@@@B@18U :B@B@B@BU, *7@BOui. ,@@B SP@B@B@B@B@Or * @@@U B@BJ.YO@B@B@i * r@B@ :B@Bk .k@B@ * B@B@ LB@@k 2i * B@BM .7jXEGqF7: OB@@L * .B@BM .B@B@B@B@B@B@. :@B@B: * .B@B@ @@MYr::ivG@B .M@B@G * B@@@S ,MB@B@, * v@@@BF .1B@B@Br * 2@@B@BL ,FB@@@B8, * r@B@B@BF, :YBB@B@B@B * L@B@B@B@P7, .ivXB@B@B@B@B@M@B@ * ,1B@B@B@B@@@BOP2L7i:,. ..,:i7LSNB@@B@B@@@B@B@B@Z5v;.LB@@ * @B@OEB@B@@@B@B@B@B@B@B@B@B@@@B@B@B@B@B@@@B@B@B@B@BM0SJ7i::::i:,u@B@ * B@Bu ::i;7vu2XNGOMB@B@BMB@B@B@B@B@B@@@B1UFuj77ii:::::::iir;r;i.YB@B * @B@L.:i:i:i::::::::::..Y@B@BMYi:i;SB@B@N:.::i:iirir;r;rii::::ivO@B@ * B@@X::,::::iirir;riri:E@B@1 ,@B@Br:;;r;rii:i::::i7JEB@@@@@B * @@@B@BBq5v7ii:::::::.2@@@i ..,.. @B@@,,:::::irv2XMB@B@B@B@2@B@: * .B@BBB@@@B@B@B@BMNP5u7@B@1 .,,:,, :. @B@P50MB@B@B@B@B@@@BS: @@B1 * E@B@ ijGB@B@B@B@B@B@B@Bi .,:,,..@@B@7 B@B@B@B@B@B@BM57. kB@B * .@B@: .,ivu5Nq@B@u ..,.. SB@B@@@B@PL7i, ,@B@ * @@@8 i@B@: . :B@B@@ B@@2 * i@@@@ 0@B@u B@@B. vB@B * ,@B@G L@B@BOv:.:iFB@B@M @B@Bi * vNi S@@B@B@B@B@BM: MB@N * 758BMqJ, * * . YO. vq :G Z: * SqOMBB@B@Br @@r rBE @B B@@@@@B@ONX8k i::::.OB1.:::.u@O.::::i @B@B@U:@@B@@BPEBu * B@@NB@k. 5@i uB@E. BM 1U2uUJvirB@@Z r@@B@B@@@B@B@B@B@B@@@B@Bi LB@B@1 BX :@k uLLLvr@BJ: * iB iBi 7@ .@M8@BGMZZ @@F ,B Pi v@ Bq @i v@ B@ * vuL7r8@S7vJL7N@Z7LLri;72. F7@Bvvv@@ @BX @@@B@B@@@@@B@@@B@B@B 7@ @F Bi @q @B@Bu @B * N@B@G@@@8@BBOMB@G@BMNXG@, B@ @@ .Bk .:u; i@: Zv 7@ Bk @,;@ ,BY @B B@ * r@ @G 5. ,@v BZ :::,.r@E .::i, @B B@ .@BL 7@ @F B:i@. .@ @M @B * 7B: ,vO, @@ iB@: @B 7@:MB@B@B@@@B@B@BM @@. B: 2@q 7@ BS @i 0@ B. @O B@ * ,r2EBB@B@B@Bi G@ @BB B@ @B @S : r@ .. 7B @F @7 B7 @ @B @B * E@B@UOBr @B@Bi L@0PB .BZ .@B@B@B@B@B@B@B@B@B@B@B@, r@ BF @i @G B@B@B B@ * 7@, kB@U ;r @@@. .@Z GBuL@iBBi vB@B@q BP:5@7 @u,. @B * LBi YB@BrB@ @@ @B:L@Br BM .M@B rB rB@J v@. Pi @XZ8r . B@ * . G@i B@BM. ,B@, @B iB@B N, 7r..q@k ,LB@B8 J@, i@B@B1r Br @@ * MB@B@B ,i B@B@B, B@: @B@B@F .@BB: P@i :OBZ .@U B@B@B: * .ll rB. : */ /* 00000000000000000000000000000000000000000000*-----------*0000000000000000000000000000000000000----------*-*000000000000000000000000000 0000000000000000000000000000000000000000000000000000**----0000000000000000000000000000000000*----*000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000--*000000000000000000000000000000000--*000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000*-*000000000000000000000000000000000**0000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000**---*0000000000000000000000000000000000000000000000*----*00000000000000000000000000000000000000 0000000000000000000000000000000000000-------000000000000000000000000000000000000000000000--------0000000000000000000000000000000000000 00000000000000000000000000000000000000-----00000000000000000000000000000000000000000000000------00000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*00000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*00000000000 0000000000000000000000000000*000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*00000000000 0000000000000000000000000000*000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*00000000000 00000000000000000000000000000*00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000-00000000000 00000000000000000000000000000*000*0000**00000000000000000000000000000000000000000000000000000000000000000000000*000000000**00000000000 000000000000000000000000000000*00000000***00000000000000000000000000000000000000000000000000000000000000000000*000000000*-000000000000 000000000000000000000000000000**00000000*-*000000000000000000000000000000000000000000000000000000000000000000**000000000--000000000000 00000000000000000000000000000000*00000000*--*00000000000000000000000000000000000000000000000000000000000000*-*000000000*-0000000000000 00000000000000000000000000000000**00000000*--*00000000000000000000000000000000000000000000000000000000000*-*0000000000*-00000000000000 00000000000000000000000000000000**0000000000*--**000000000000000000000000000000000000000000000000000000*--*000000*000-**00000000000000 0000000000000000000000000000000000000000000000*---*000000000000000000000000000000000000000000000000**---000000000000*-0000000000000000 00000000000000000000000000000000000**00000000000**----*00000000000000000000000000000000000000000**---*000000000000*-*00000000000000000 0000000000000000000000000000000000000*00000000000000*----***0000000000000000000000000000000***----*00000000000000*-*000000000000000000 0000000000000000000000000000000000000***0000000000000000*---------****0000000000000***--------*0000000000000000*--*0000000000000000000 0000000000000000000000**0000000000000000***000000000000000000***------------------------**000000000000000000**-**000000000000000000000 00000000000000000000*--*000--000000000000***00000000000000000000000000*********0*00000000000000000000000000*-**00000000000000000000000 00000000000000000000--*000--*000000000000000--*000000000000000000000000000000000000000000000000000000000*--**0000000000000000000000000 0000000000000000000* -0000*-000000000000000*---**00000000000000000000000000000000000000000000000000000*0* -000000000000000000000000000 0000000000000000000* -0000*-000000000000000--00000***0000000000000000000000000000000000000000000000000000--*00000000000000000000000000 00000000000000000000--0000--0000000000000--*0000000000*****00000000000000000000000000000000*******0000000---00000000000000000000000000 00000000000000000000--0000* -0000000000*--0000*0000000000000******00000000000000000000*******0000000000000--00000000000000000000000000 00000000000000000000- 00000- 00000000*--*000** -000000000000000000*******************0*0000000000000000000--00000000000000000000000000 000000000000000000000--0000- 000000*--*000*-----*0000000000000000000000000000000000000000000000000000000000 -0000000000000000000000000 000000000000000000000*--*000--000*-*0000--*0000-*0000000000000000000000000000000000000000000000000000000000--0000000000000000000000000 00000000000000000000000-*0000*0*--000*---000000--0000000000000000000000000000000000000000000000000000000000--*000000000000000000000000 000000000000000000000000000000--000---000000000-*00000000000000000000000000000000000000000000000000000000000--000000000000000000000000 000000000000000000000000000*--*00--*00000000000- 00000000000000000000000000000000000000000000000000000000000--000000000000000000000000 000000000*---------------- -*0----------------- -------------------------------*******--------------------- ------------------------ 0000000*--00000000000000- --- *0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000- - 00000*--000000000000000- ---000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000--*0 000*--000000000--000000--0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000---000 0*--000000000000-*000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*--00000 --00000000000000*-00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000--*000000 000000000000000*--0**--0*--000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000--*0000000- 000000000000000000000* -*000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*--0000000*-- 000000000000000000000*-*000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000--*0000000--00 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*--*0000000*---00 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000---0000000*--- -00 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*--00000000--000--00 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000--*0000000---000* -00 000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000- -0000000* -00000* -00 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000*--0000000*---000000- -00 */ /* .:: ,, .: :, :. :LuqL 5B@ :v 77L21F5F5F5F1F5S15Uv7, :@B 0@U .B@ L@P B@B@@@B@B@B@@B L@B B@B@, @BB2XSPSPkPXPkPXPF2B@B .@B@B@B@B@@@B@B@B@B@@@B@B@B@B@B@ :@@@@BBMOB@BGM@B@BME@@@EMB@B@B@r ,Yi: @B2 iB@ 2@@@7 B@, 8Bq vriii:.:0@@:ii::,:::B@B::iiii77 ,E1uJuJJ7GB@7LUk2ULvB@B7LjJjjSq: B@7 @B i7 @B@B@B@B@B@B@B@B@B@B@k @B .BZ u@. : ,@N 7B2 0EqEqX2@B@1N0Z0ZSqB@qX0ZNPUYLSZ8 B@ NBP :@B 1@BMX0uj2EEZN15, 8@B@B@@@GGB@7 5@B@BOM@B@B@B. @B@B@B@@@B@B@B@B@B@B@B@B@B@B@B@B @B@B@B@B@B@B@B@B@B@B@q @B@B@B@B@@@u S@B2qOOMOMM@BMB@L @@7 B@. @Bv @@v . B@: k@v :i;.,...q5::B@k @Bi 8@@B@B@B@B@v BB@B@B@B@@@B. B@L .,7 0B@ SB@S :5jj7vi::iiiii:..,:iii::;77LY25 B@ @B u@20B@B@B@B@N @@: B@ .: B@ :: .:v28P@B@@@B@B@, ,@@ u@B@. YB@B@ME0OB@B@@@B@BMB@B@BBOBB@B@. L@@ OBS B@: JB@ @B. v@BLuXP0qXvL: 1@B7ukXE00SYvL @@@B@B@B@Z. B@kLB@B: 7Ei @@; @B: B@ @B .@O B@ LO1i , @B0 ;BX7. ,..P@B @Bu 1B@B5 :: :@B B@@@B@B@@@B@B@ 7@@ U@u B@i,::.PB@ @B .7OBGu Z@v rNBOFi 7B8 B@5 7B@B@B@ B@B i@B@7 @BN.::i:i:i:ii 17 @B @B@B@B@MMY B@ u@OBUMBi :@BNBYv@F @B0 u@B@B@L kB@; @@; 0@B.J@@O: B@i ,:ii7@B@B@@@u SZ i@B LB@@@B@5Y, B@, 5@@@B@GFY: ZBu :5rr:5B@J MBM: iB@@k:@@@ ,NB@E k@@B@B@B@qEZMMBM@MBB@Br @B@B@OY77:, :MSUjuukB@Br iBvUr. .8@B i5::r YB@ .B@B@BZ: 0B@B8 @BO .:i:77uU5uFSkFkFXXq B@B@@@GU. ,@B@B@BM: B@B@B@B7 .:7kq ;@B, , @B. i@M .B@, N@@ .BO :,. .:.. LB@@@B@B@B@B@@ :B@, EB@O, B@i U@@ ,q@BX 1@B ,q@B0: ,B@B@B@B@B@B@1 @B@B@B@B@B@B@ kri. M@@ @B: u@B@J @B@B@B@B@@@Bi J@@@B@B@B@B@B irrvi:u@BjLJ7@B@7YYLB@Bj::rir @Bj i@B EBO @@: :1 iiii:i::,:B@: uB@.::i:i:iii @B@qquvrLu1127rrUU5Uvrrv5q@B@. .,iiiii::B@L .,:iiiii:E@@ YLLvv7iB@Bi7YLYL7r@@ErLLL7r::iYU @@i Y@@ B@k . . ... @B, B@B@B@B@B@BF @B@B@B@B@@@B @@B@B@B@B@@@B@B@B@B@B@B@B@B@B@B@. B@i uB@ r7. ,B@MMMBMBMBMBMBMMG@B@ 7v r@M LB8 E@O PBM . vB@B@B@@@B@Bi J@B@B@B@B@@@7 .@B P@8 @BX.::i:i: B@2,:::i:i. . Z@M ; ;@B i@@@ ,ULYLJLL77@@i uB@ivLYLJLJu: ,B@B@B@B@B@B@B@B@B@B@ BOEOB@B@B@B@q BZNO@B@B@B@B@@ ,:i7JB@B@B@B@@u B@: :B@Bv @Bi J@B 2J uB@ :u: @@r @BL 7@X: 8BZ B@B@B@B@B@,i. kBBi@B@L B@i j@@ uYjvJ2kSk1jM@@u2kFS1uLuJUi iu@B@O B@i .iNB@Bj B@u . Z@M :@B@Mi : rEXqXXXPS5U@Bi Y@Bj1XXqkXXN07 B@Bq088OOGk@B@SE8OZZNq5@B@ i7:, @@, ::i2r @B7 MB@ ,8B@B@B kB@ Y@@B@B@BBOGB@i uB@EMB@B@B@B@j @Bi 7@B G@8 ukBB@@@B@P B@ .75BB@@@B@: B@: O@B 7u@B@BO, v@@v B@G @Bi J@B B@Y uB@ 7:,.i@BS ,B@B1: .@B N@@BL @B. 5ri:r@B@ k@BL. ,@B@q:5@B B@r 1@@ @B7 F@B @B@B@Or .i.,,:1@B8 r,:::u@B@ @B@B@B1 .q@B@B: @Br L@B 5B@ kB@B@@@5. r@@@@B@Z; ,ijN B@L . B@5 .:...,:,:,. ,,:....... ... . :@B@B@@@B@B@@@i @B1 j@B@. .@B .B@B@B@@@B@B@B@B@B G@B@B@B@B@B@B .B@B@B@@@B@B@v 7;L7ri. @@@B@B@@ B@B@B@@@B@B@@ NLrr:0B@ B@2 YB@@N UBB ... . .@B@Bi B@ @Br B@BBB@8 B@ JBE :B@ :@B BBk .O: E@B@B@B@B@B@P .M@BS ..,:,:,.7@@ ,.:,:::.,B@i @B :BS BB B@ @B :L77rr:E@@ir7vvvr:B@B:rv7ri:::rJ :7ij@Biir:@BM :@B@i v@B@@@B@B@@@ UB@B@B@B@B@BL B@ i@5 M@ S@v UB@B@@M B@ 8B@B@B@B@B@B@B@B@B@@@B@B@@@B@B@@L JBM @@i 5B@ @B. @@ @B ;@F BB @B O@L .@B @B 7B@ i@B @@, @B L@B ,B@..,:,,.. :@B..,,:,:. . B@ i@5 M@ .B@ NB. B@ @@ ;@B ,, B@ @@B. U@B 0BE @B@B@B@B@B@B@B@B@B@ LBEOB@@@B@B@B UO0G@B@B@B@B@Bi @B rBS MB. :@@ X@, @B @B ,;7B@@B@B@B@B @B5 MB@q @B7 B@ Y@B :@5. B@ OOv @@ B@ i@5 M@. jB5 kB. B@ B@ 7B@B@B@B@@1r: ;@B.Z@@O iB@@r B@j vB@ ,1@B@B; :@B i0B@B@ @B @B ,BF MB. @B 2@5i7@B @B :: 7B@ B@B@u 7@B@B Y@@ j , r@@ i :0 ,B@ B@LLG@F M@ @@ 0@@B@MZ B@ L@B v@B@@@: :@B: B@B@B1. jB@ :LLkBB@B@B 7@B :7L0@B@@@B :@@ @@MO@BO BB2B@B@7 Y@ @@ 7B@ .7B@B@B7 :B@u qB@ .@B@ .@B@: 7@B O@@B7, BBO B@BMi SB@ B@ : B@.:i: B@ u::.,B@B LB@Gi .B@B2.:B@i uB@B7 rL::,:@B@ :. ,P@@: :, .:uB@r @B. .:. U@@ B@B@BBS 5B@BM: MB v@@@@@Mv @@B@B@Bv B@@@B@Bu M@ .@B@B@X */ #include<bits/stdc++.h> #define int long long using namespace std; const int inf=1<<30; vector<int>v1,v2,v3,v4; signed main(){ int n,w; cin>>n>>w; int we,vl; cin>>we>>vl; int cmp=we;v1.push_back(vl); for(int i=1;i<n;i++){ int we,vl; cin>>we>>vl; if(we==cmp)v1.push_back(vl); if(we==cmp+1)v2.push_back(vl); if(we==cmp+2)v3.push_back(vl); if(we==cmp+4)v4.push_back(vl); } sort(v1.begin(),v1.end()); sort(v2.begin(),v2.end()); sort(v3.begin(),v3.end()); sort(v4.begin(),v4.end()); int ans=0; for(int sum=1;sum<=n;sum++) for(int i=0;i<=v1.size();i++) for(int j=0;j<=v2.size();j++){ int k=sum-i-j; int w1=w; if(k<0)continue; if(k>v3.size())continue; w1-=i*cmp; w1-=j*(cmp+1); w1-=k*(cmp+2); if(w1<0)continue; int l=w1/(cmp+3); if(l>v4.size())l=v4.size(); int gt=0; for(int g=0;g<i;g++)gt+=max(0,v1[g]); for(int g=0;g<j;g++)gt+=max(0,v2[g]); for(int g=0;g<k;g++)gt+=max(0,v3[g]); for(int g=0;g<l;g++)gt+=max(0,v4[g]); ans=max(ans,gt); } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:236:60: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)' 236 | for(int g=0;g<i;g++)gt+=max(0,v1[g]); | ~~~^~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:198: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:236:60: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 236 | for(int g=0;g<i;g++)gt+=max(0,v1[g]); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:236:60: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 236 | for(int g=0;g<i;g++)gt+=max(0,v1[g]); | ~~~^~~~~~~~~ a.cc:237:60: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)' 237 | for(int g=0;g<j;g++)gt+=max(0,v2[g]); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:237:60: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 237 | for(int g=0;g<j;g++)gt+=max(0,v2[g]); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:237:60: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 237 | for(int g=0;g<j;g++)gt+=max(0,v2[g]); | ~~~^~~~~~~~~ a.cc:238:60: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)' 238 | for(int g=0;g<k;g++)gt+=max(0,v3[g]); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:238:60: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 238 | for(int g=0;g<k;g++)gt+=max(0,v3[g]); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:238:60: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 238 | for(int g=0;g<k;g++)gt+=max(0,v3[g]); | ~~~^~~~~~~~~ a.cc:239:60: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)' 239 | for(int g=0;g<l;g++)gt+=max(0,v4[g]); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:239:60: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}) 239 | for(int g=0;g<l;g++)gt+=max(0,v4[g]); | ~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:239:60: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 239 | for(int g=0;g<l;g++)gt+=max(0,v4[g]); | ~~~^~~~~~~~~
s347649738
p03732
C++
#include<cstdio> #include<iostream> #include<cmath> #include<algorithm> #include<string> #include<cstring> #include<cctype> #include<queue> #include<stack> #include<map> #include<set> #include<iomanip> #include<sstream> #include<cstdlib> #include<ctime> #include<list> #include<deque> #include<bitset> #include<fstream> #define ld double #define ull unsigned long long #define ll long long #define pii pair<int,int > #define iiii pair<int,pii > #define mp make_pair #define INF 1000000000 #define MOD 1000000007 #define rep(i,x) for(int (i)=0;(i)<(x);(i)++) inline int getint() { int x=0,p=1;char c=getchar(); while (c<=32)c=getchar(); if(c==45)p=-p,c=getchar(); while (c>32)x=x*10+c-48,c=getchar(); return x*p; } using namespace std; // int n; ll pre[4][1000]; vector<ll>cnt[4]; ll res=0,xx,yy,w; // int main() { n=getint();w=1ll*getint(); xx=getint();yy=getint(); cnt[0].push_back(yy); rep(i,n-1) { int x=getint(),y=getint(); cnt[x-xx].push_back(y); } rep(i,4) { sort(cnt[i].begin(),cnt[i].end()); reverse(cnt[i].begin(),cnt[i].end()); pre[i][0]=0; for(int j=1;j<=cnt[i].size();j++) pre[i][j]=pre[i][j-1]+1ll*cnt[i][j-1]; } rep(i,cnt[0].size()+1) rep(j,cnt[1].size()+1) rep(k,cnt[2].size()+1) { ll l=w-1ll*i*xx-1ll*j*(xx+1)-1ll*k*(xx+2); if(l<0)continue; l=min(l,1ll*cnt[3].size()); ll ans=pre[0][i]+pre[1][j]+pre[2][k]+pre[3][l]; res=max(res,ans); } cout<<res<<endl; return 0; }
a.cc: In function 'int main()': a.cc:68:38: error: no matching function for call to 'min(long long int&, long long unsigned int)' 68 | l=min(l,1ll*cnt[3].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:68:38: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int') 68 | l=min(l,1ll*cnt[3].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:4: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:68:38: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 68 | l=min(l,1ll*cnt[3].size()); | ~~~^~~~~~~~~~~~~~~~~~~~~
s962475821
p03732
C++
#include<bits/stdc++.h> using namespace std; int dp[100][1000000000]; int w[1000000000],v[10000000]; int main(){ int n,W; cin>>n>>W; for(int i=0;i<n;++i) cin>>w[i]>>v[i]; for(int i=1;i<=n;++i){ for(int j=1;j<=W;++j){ if(j-w[i-1]>=0) dp[i][j]=max(dp[i-1][j-w[i-1]]+v[i-1],dp[i-1][j]); else dp[i][j]=dp[i-1][j]; } } cout<<dp[n][W]<<endl; return 0; }
/tmp/ccy80oWN.o: in function `main': a.cc:(.text+0x49): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccy80oWN.o a.cc:(.text+0x75): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccy80oWN.o a.cc:(.text+0xbe): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccy80oWN.o a.cc:(.text+0x116): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccy80oWN.o a.cc:(.text+0x157): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccy80oWN.o collect2: error: ld returned 1 exit status
s295460930
p03732
C++
#include <cstdio> #include <algorithm> using namespace std; int N,W; int w1; vector<int> v[4]; void f(int a,int b,int c,int d,int ans){ ans = max(ans, v[0][a] + v[1][b] + v[2][c] + v[3][d]); if(a==0 && b==0 && c==0){ printf("%d\n",ans); return; } if(d==0){ } } int main(){ scanf("%d%d",&N,&W); for(int i=0;i<4;i++){ v[i].push_back(0); } for(int i=0,x,y;i<N;i++){ scanf("%d%d",&x,&y); if(i==0)w1 = x; v[x-w1].push_back(y); } for(int i=0;i<4;i++){ sort(v[i].begin(),v[i].end()); reverse(v[i].begin()+1,v[i].end()); for(int j=1;j<v[i].size();j++){ v[i][j] += v[i][j-1]; } } int ans = 0; for(int i=0;i<v[0].size();i++){ for(int j=0;j<v[1].size();j++){ for(int k=0;k<v[2].size();k++){ for(int l=0;l<v[3].size();l++){ if(w1*(i+j+k+l)+j+2*k+3*l <= W){ ans = max(ans, v[0][i]+v[1][j]+v[2][k]+v[3][l]); } } } } } printf("%d\n",ans); return 0; }
a.cc:7:1: error: 'vector' does not name a type 7 | vector<int> v[4]; | ^~~~~~ a.cc: In function 'void f(int, int, int, int, int)': a.cc:10:20: error: 'v' was not declared in this scope 10 | ans = max(ans, v[0][a] + v[1][b] + v[2][c] + v[3][d]); | ^ a.cc: In function 'int main()': a.cc:24:9: error: 'v' was not declared in this scope 24 | v[i].push_back(0); | ^ a.cc:29:9: error: 'v' was not declared in this scope 29 | v[x-w1].push_back(y); | ^ a.cc:32:14: error: 'v' was not declared in this scope 32 | sort(v[i].begin(),v[i].end()); | ^ a.cc:40:19: error: 'v' was not declared in this scope 40 | for(int i=0;i<v[0].size();i++){ | ^
s371099879
p03732
C++
#include "bits/stdc++.h" using namespace std; #define MOD 1000000007 #define Nmax 200010 #define FOR(i,a,b) for(long long i=(a);i<(b);i++) #define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--) #define REP(i,n) FOR(i,0,n) #define RREP(i,n) RFOR(i,0,n) #define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr) #define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr) #define dump(x) cout << #x << " = " << (x) << endl; #define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; typedef long long ll; typedef pair<ll,ll> P; typedef vector<P> Graph; int main() { int N; cin >> N; ll W,w,w0,vv; vector<ll> v(4); cin >> W >> w0 >> vv; v[0].push_back(vv); REP(i,N-1){ cin >> w >> vv; v[w-w0].push_back(vv); } REP(i,4){ sort(v[i].begin(),v[i].end()); reverse(v[i].begin(),v[i].end()); } ll mac=0,sum[4][110]={}; //[0]が0の累積和 REP(i,4) REP(j,v[i].size()) sum[i][j+2]+=sum[i][j+1]+v[i][j]; REP(w1,W/w0+1){ REP(w2,W/(w0+1)+1){ REP(w3,W/(w0+2)+1){ REP(w4,W/(w0+3)+1){ if(w1*w0+w2*(w0+1)+w3*(w0+2)+w4*(w0+3)>W) break; if(w4>v[3].size()||w3>v[2].size()||w2>v[1].size()||w1>v[0].size()) break; mac = max(mac,sum[0][w1]+sum[1][w2]+sum[2][w3]+sum[3][w4]); } } } } cout << mac << endl; return 0; }
a.cc: In function 'int main()': a.cc:23:14: error: request for member 'push_back' in 'v.std::vector<long long int>::operator[](0)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} 23 | v[0].push_back(vv); | ^~~~~~~~~ a.cc:26:25: error: request for member 'push_back' in 'v.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)(w - w0)))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} 26 | v[w-w0].push_back(vv); | ^~~~~~~~~ a.cc:29:27: error: request for member 'begin' in 'v.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} 29 | sort(v[i].begin(),v[i].end()); | ^~~~~ a.cc:29:40: error: request for member 'end' in 'v.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} 29 | sort(v[i].begin(),v[i].end()); | ^~~ a.cc:30:30: error: request for member 'begin' in 'v.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} 30 | reverse(v[i].begin(),v[i].end()); | ^~~~~ a.cc:30:43: error: request for member 'end' in 'v.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} 30 | reverse(v[i].begin(),v[i].end()); | ^~~ a.cc:34:28: error: request for member 'size' in 'v.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} 34 | REP(j,v[i].size()) sum[i][j+2]+=sum[i][j+1]+v[i][j]; | ^~~~ a.cc:5:43: note: in definition of macro 'FOR' 5 | #define FOR(i,a,b) for(long long i=(a);i<(b);i++) | ^ a.cc:34:17: note: in expansion of macro 'REP' 34 | REP(j,v[i].size()) sum[i][j+2]+=sum[i][j+1]+v[i][j]; | ^~~ a.cc:34:65: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type {aka long long int}[long long int]' for array subscript 34 | REP(j,v[i].size()) sum[i][j+2]+=sum[i][j+1]+v[i][j]; | ^ a.cc:40:52: error: request for member 'size' in 'v.std::vector<long long int>::operator[](3)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} 40 | if(w4>v[3].size()||w3>v[2].size()||w2>v[1].size()||w1>v[0].size()) break; | ^~~~ a.cc:40:68: error: request for member 'size' in 'v.std::vector<long long int>::operator[](2)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} 40 | if(w4>v[3].size()||w3>v[2].size()||w2>v[1].size()||w1>v[0].size()) break; | ^~~~ a.cc:40:84: error: request for member 'size' in 'v.std::vector<long long int>::operator[](1)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} 40 | if(w4>v[3].size()||w3>v[2].size()||w2>v[1].size()||w1>v[0].size()) break; | ^~~~ a.cc:40:100: error: request for member 'size' in 'v.std::vector<long long int>::operator[](0)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} 40 | if(w4>v[3].size()||w3>v[2].size()||w2>v[1].size()||w1>v[0].size()) break; | ^~~~
s786885254
p03732
C++
4 1 10 100 10 100 10 100 10 100
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 4 1 | ^
s969396291
p03732
C++
#include <bits/stdc++.h> using namespace std; #define INF 0x3f3f3f3f typedef long long ll; const int N = 110; int vis[N][N]; int t[100000]; ll a,b,c,d,n,w,sumv,sumw,maxx; ll wa[1000],wb[1000],wc[1000],wd[1000]; ll va[1000],vb[1000],vc[1000],vd[1000]; struct node { ll w,v; }g[1000]; node aa[1000],bb[1000],cc[1000],dd[1000]; int cmp(node a,node b) { return a.v>b.v; } void init() { sort(aa+1,aa+a+1,cmp); sort(bb+1,bb+b+1,cmp); sort(cc+1,cc+c+1,cmp); sort(dd+1,dd+d+1,cmp); } void inv() { wa[0]=0; va[0]=0; for(int i=1;i<=a;i++) { wa[i]=wa[i-1]+aa[i].w; va[i]=wa[i-1]+aa[i].v; } wb[0]=0; vb[0]=0; for(int i=1;i<=b;i++) { wb[i]=wb[i-1]+bb[i].w; vb[i]=vb[i-1]+bb[i].v; } wc[0]=0; vc[0]=0; for(int i=1;i<=c;i++) { wc[i]=wc[i-1]+cc[i].w; vc[i]=vc[i-1]+cc[i].v; } wd[0]=0; vd[0]=0; for(int i=1;i<=d;i++) { wd[i]=wd[i-1]+dd[i].w; vd[i]=vd[i-1]+dd[i].v; } } int main() { a=0; b=0; c=0; d=0; for(int i=0;i<1000;i++) { wa[i]=wb[i]=wc[i]=wd[i]=0; va[i]=vb[i]=vc[i]=vd[i]=0; } for(int i=0;i<10000;i++) { t[i]=1; } for(int i=0;i<100;i++) { for(int j=0;j<100;j++) { vis[i][j]=-1; } } cin>>n>>w; for(int i=1;i<=n;i++) { cin>>g[i].w>>g[i].v; if(g[i].w==g[1].w) { a++; aa[a]=g[i]; } if(g[i].w==g[1].w+1) { b++: bb[b]=g[i]; } if(g[i].w==g[1].w+2) { c++; cc[c]=g[i]; } if(g[i].w==g[1].w+3) { d++; dd[d]=g[i]; } } init(); inv(); sumv=0; sumw=0; //cout<<a<<b<<c<<d<<endl; for(int i=0;i<=a;i++) { //cout<<1<<endl; for(int j=0;j<=b;j++) { for(int k=0;k<=c;k++) { for(int q=0;q<=d;q++) { sumw=wa[i]+wb[j]+wc[k]+wd[q]; sumv=va[i]+vb[j]+vc[k]+vd[q]; //cout<<sumw<<sumv<<1<<endl; if(sumw<=w) { maxx=max(maxx,sumv); } } } } } cout<<maxx<<endl; return 0; }
a.cc: In function 'int main()': a.cc:95:15: error: expected ';' before ':' token 95 | b++: | ^ | ;
s921169070
p03732
C++
#include<iostream> #include<string> #include<algorithm> #include<cmath> #include<iomanip> #include<cstring> #include<map> #include<vector> #include<queue> #include<climits> #include<set> #include<utility> using namespace std; typedef long long int ll; ll dp[101][101]; ll N, W, w[101], v[101]; int rec(int i, int j){ if(dp[i][j] >= 0){ return dp[i][j]; } int res; if(i == N){ res = 0; } else if(j < w[i]){ res = rec(i + 1, j); } else { res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]); } return dp[i][j] = res; } int main(){ cin >> N >> W; for(int i = 0; i < N; i++){ cin >> w[i] >> v[i]; } memset(dp, -1, sizeof(dp)); cout << rec(0, W) << endl; return 0; }
a.cc: In function 'int rec(int, int)': a.cc:29:26: error: no matching function for call to 'max(int, ll)' 29 | res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:29:26: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'}) 29 | res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:29:26: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 29 | res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s461189407
p03732
C++
#include <bits/stdc++.h> using namespace std; #define REP(i, s, n) for (int i = s; i < n; ++i) #define rep(i, n) REP(i, 0, n) #define SORT(c) sort((c).begin(), (c).end()) #define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>()) #define IINF INT_MAX #define LLINF LLONG_MAX #define DEBUG true // sort(a.begin(), a.end(), std::greater<int>()); /* std::vector<std::string> split(const std::string &input, char delimiter) { std::istringstream stream(input); std::string field; std::vector<std::string> result; while (std::getline(stream, field, delimiter)) { result.push_back(field); } return result; } */ /// dp index w #define MAX_N 101 #define MAX_W 1000 pair<int, int> dp[MAX_N][MAX_W]; //value amout int main() { int n; long long int w; cin >> n >> w; //table init rep(i, MAX_N) { rep(j, MAX_W) { dp[i][j] = make_pair(-1, 0); } } int bios; vector<pair<int, int>> items; cin >> bios; int value; cin >> value; items.push_back(make_pair(1, value)); rep(i, n - 1) { int weight; cin >> weight >> value; items.push_back(make_pair(weight - bios + 1, value)); } dp[0][0] = make_pair(0, 0); //de[0][hoge]は使わない pair<int, int> max_pair = make_pair(0, 0); REP(i, 1, n + 1) { rep(j, MAX_W) { if (dp[i - 1][j].first != -1) { //入れない //更新するかどうか if (dp[i][j].first < dp[i - 1][j].first) { dp[i][j] = dp[i - 1][j]; } //値が同じなら数が少ない方 else if (dp[i][j].first == dp[i - 1][j].first) { dp[i][j].second = min(dp[i][j].first, dp[i - 1][j].first); } //入れる OFのチェック bool hoge = false; if (w - (bios - 1) * (dp[i - 1][j].second + 1) < 0 - j - items[i - 1]) { continue; } else { //値を更新するかどうか if (dp[i][j + items[i - 1].first].first < dp[i - 1][j].first + items[i - 1].second) { dp[i][j + items[i - 1].first].first = dp[i - 1][j].first + items[i - 1].second; dp[i][j + items[i - 1].first].second = dp[i - 1][j].second + 1; } //値が同じなら、数の少ない方 else if (dp[i][j + items[i - 1].first].first == dp[i - 1][j].first + items[i - 1].second) { dp[i][j + items[i - 1].first].second = min(dp[i - 1][j].second + 1, dp[i][j + items[i - 1].first].second); } //最大値の更新 if (dp[i][j + items[i - 1].first].first > max_pair.first) { max_pair = dp[i][j + items[i - 1].first]; } } } } } // rep(i, 10) // { // rep(j, 10) // { // cout << "(" << dp[i][j].first << "," << dp[i][j].second << ")"; // } // cout << endl; // } // rep(i, items.size()) // { // cout << items[i].first << " " << items[i].second << endl; // } // cout << "bios" << bios << endl; cout << max_pair.first << endl; return 0; }
a.cc: In function 'int main()': a.cc:77:72: error: no match for 'operator-' (operand types are 'int' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'}) 77 | if (w - (bios - 1) * (dp[i - 1][j].second + 1) < 0 - j - items[i - 1]) In file included from /usr/include/c++/14/bits/stl_algobase.h:67, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 618 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed: a.cc:77:85: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 77 | if (w - (bios - 1) * (dp[i - 1][j].second + 1) < 0 - j - items[i - 1]) | ^ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1790 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed: a.cc:77:85: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 77 | if (w - (bios - 1) * (dp[i - 1][j].second + 1) < 0 - j - items[i - 1]) | ^ In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/complex:370:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const complex<_Tp>&)' 370 | operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:370:5: note: template argument deduction/substitution failed: a.cc:77:85: note: mismatched types 'const std::complex<_Tp>' and 'int' 77 | if (w - (bios - 1) * (dp[i - 1][j].second + 1) < 0 - j - items[i - 1]) | ^ /usr/include/c++/14/complex:379:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const _Tp&)' 379 | operator-(const complex<_Tp>& __x, const _Tp& __y) | ^~~~~~~~ /usr/include/c++/14/complex:379:5: note: template argument deduction/substitution failed: a.cc:77:85: note: mismatched types 'const std::complex<_Tp>' and 'int' 77 | if (w - (bios - 1) * (dp[i - 1][j].second + 1) < 0 - j - items[i - 1]) | ^ /usr/include/c++/14/complex:388:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const _Tp&, const complex<_Tp>&)' 388 | operator-(const _Tp& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:388:5: note: template argument deduction/substitution failed: a.cc:77:85: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::complex<_Tp>' 77 | if (w - (bios - 1) * (dp[i - 1][j].second + 1) < 0 - j - items[i - 1]) | ^ /usr/include/c++/14/complex:465:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&)' 465 | operator-(const complex<_Tp>& __x) | ^~~~~~~~ /usr/include/c++/14/complex:465:5: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/valarray:605, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166: /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:77:85: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 77 | if (w - (bios - 1) * (dp[i - 1][j].second + 1) < 0 - j - items[i - 1]) | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:77:85: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 77 | if (w - (bios - 1) * (dp[i - 1][j].second + 1) < 0 - j - items[i - 1]) | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:77:85: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 77 | if (w - (bios - 1) * (dp[i - 1][j].second + 1) < 0 - j - items[i - 1]) | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:77:85: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 77 | if (w - (bios - 1) * (dp[i - 1][j].second + 1) < 0 - j - items[i - 1]) | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:77:85: note: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 77 | if (w - (bios - 1) * (dp[i - 1][j].second + 1) < 0 - j - items[i - 1]) | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const valarray<_Tp>&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:77:85: note: mismatched types 'const std::valarray<_Tp>' and 'int' 77 | if (w - (bios - 1) * (dp[i - 1][j].second + 1) < 0 - j - items[i - 1]) | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:77:85: note:
s834694143
p03732
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<ll, ll> P; #define pb push_back #define rep(i, a, n) for(int i = (a); i < (n); i++) #define dep(i, a, n) for(int i = (a); i >= (n); i--) #define mod (ll)(1e9+7) __attribute__((constructor)) void initial() { cin.tie(0); ios::sync_with_stdio(false); } map<ll, ll> dp[101]; signed main() { ll n, w; cin >> n >> w; P m[100]; rep(i, 0, n) cin >> m[i].first >> m[i].second; dp[0][0] = 0; rep(i, 0, n) { for(auto it = dp[i].begin(); it != dp[i].end(); it++) { dp[i + 1][it->first + m[i].first] = max(dp[i + 1][it->first + m[i].first], dp[i][it->first] + m[i].second); dp[i + 1][it->first] = max(dp[i + 1][it->first], (int)it->second); } } int ans = 0; for(auto it = dp[n].begin(); it != dp[n].end(); it++) { if(it->first <= w) ans = max(ans, it->second); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:31:33: error: no matching function for call to 'max(std::map<long long int, long long int>::mapped_type&, int)' 31 | dp[i + 1][it->first] = max(dp[i + 1][it->first], (int)it->second); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:31:33: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 31 | dp[i + 1][it->first] = max(dp[i + 1][it->first], (int)it->second); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:31:33: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 31 | dp[i + 1][it->first] = max(dp[i + 1][it->first], (int)it->second); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:36:33: error: no matching function for call to 'max(int&, long long int&)' 36 | if(it->first <= w) ans = max(ans, it->second); | ~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:36:33: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 36 | if(it->first <= w) ans = max(ans, it->second); | ~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:36:33: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 36 | if(it->first <= w) ans = max(ans, it->second); | ~~~^~~~~~~~~~~~~~~~~
s660791396
p03732
C
#include <bits/stdc++.h> #define inf (1<<29) #define sq(n) ((n)*(n)) #define rep(i,n) for(int i=0;i<n;i++) #define rev(i,n) for(int i=n-1;i>=0;i--) #define MEMSET(a) memset(a,0,sizeof(a)) #define pb push_back using namespace std; int main(){ int N,W; cin>>N>>W; int w,v,w1; vector<int> V[4]; cin>>w1>>v; V[0].pb(v); rep(i,N-1){ cin>>w>>v; V[w-w1].pb(v); } rep(i,4){ sort(V[i].begin(),V[i].end()); reverse(V[i].begin(),V[i].end()); rep(j,(int)V[i].size()-1)V[i][j+1]+=V[i][j]; } int a1,a2,a3,a4; long long max; a1=a2=a3=a4=max=0; rep(i,V[0].size()+1){ rep(j,V[1].size()+1){ rep(k,V[2].size()+1){ rep(l,V[3].size()+1){ int t=(i+j+k+l)*w1+j+2*k+3*l; long long r=0; if(i)r+=V[0][i-1]; if(j)r+=V[1][j-1]; if(k)r+=V[2][k-1]; if(l)r+=V[3][l-1]; if(t<=W&&r>max){ max=r; a1=i; a2=j; a3=k; a4=l; } } } } } long long ans=0; if(a1)ans+=V[0][a1-1]; if(a2)ans+=V[1][a2-1]; if(a3)ans+=V[2][a3-1]; if(a4)ans+=V[3][a4-1]; cout<<ans<<endl; return 0; }
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory 1 | #include <bits/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s739249432
p03732
C++
#include <iostream> #include <vector> #include <utility> #include <map> #include <algorithm> using namespace std; typedef long long ll; ll N, W; map<pair<ll, ll> , ll> dp; //<i番目まで見たときの重さに対する価値の最大値> vector<ll> w, v; ll func(ll, ll); int main(){ cin >> N >> W; ll wt, vt; w.push_back(0); v.push_back(0); for(int i=1; i<=N; i++) { cin >> wt >> vt; w.push_back(wt); v.push_back(vt); } for(int i=0; i<=W; i++){ dp[make_pair(0, i)] = 0; } for(int i=0; i<=N; i++){ dp[make_pair(i, 0)] = 0; } ll ans=0; for(int i=max(w[0]-3, 0); i<=W; i++){ ans = max(ans, func(N, i)); } cout << ans << endl; return 0; } ll func(ll i, ll wm){ pair<ll, ll> tmp = make_pair(i, wm); if(dp.find(tmp)==dp.end()){ if(wm<w[i]){ return dp[tmp]=func(i-1, wm); } else{ return dp[tmp]=max(func(i-1, wm), func(i-1, wm-w[i])+v[i]); } } else{ return dp[tmp]; } }
a.cc: In function 'int main()': a.cc:32:16: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type, int)' 32 | for(int i=max(w[0]-3, 0); i<=W; i++){ | ~~~^~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:32:16: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 32 | for(int i=max(w[0]-3, 0); i<=W; i++){ | ~~~^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:5: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:32:16: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 32 | for(int i=max(w[0]-3, 0); i<=W; i++){ | ~~~^~~~~~~~~~~
s247809590
p03732
C++
#include <iostream> #include<cstdlib> #include<queue> #include<set> #include<vector> #include<string> #include<algorithm> #include<stack> #include<map> #include<cstdio> using namespace std; #define rep(i,a) for(int i=0;i<a;i++) #define mp make_pair #define pb push_back #define ll __int64 //#define ll long long #define P pair<ll,ll> ll k; int n,m; int v[1000],w[1000]; vector<int> t[5]; int main(){ cin>>n>>m;; rep(i,5)t[i].resize(0); int k; rep(i,n){ cin>>w[i]>>v[i]; k=w[0]; t[k+3-w[i]].push_back(v[i]); } for(int i=0;i<=3;i++){ //cout<<t[i].size()<<endl; sort(t[i].begin(),t[i].end(),greater<int>()); } ll ans=0; rep(i,max(1,(int)t[0].size()+1)){ rep(j,max(1,(int)t[1].size()+1)){ rep(x,max(1,(int)t[2].size()+1)){ rep(y,max(1,(int)t[3].size()+1)){ ll tmp=0,we=0; rep(z,i)tmp+=t[0][z],we+=k+3; rep(z,j)tmp+=t[1][z],we+=k+2; rep(z,x)tmp+=t[2][z],we+=k+1; rep(z,y)tmp+=t[3][z],we+=k; //cout<<i<<" "<<j<<" "<<x<<" "<<y<<" "<<" "<<we<<" "<<tmp<<endl; if(we<=m)ans=max(ans,tmp); } } } } cout<<ans<<endl; return 0; }
a.cc:15:12: error: '__int64' does not name a type; did you mean '__int64_t'? 15 | #define ll __int64 | ^~~~~~~ a.cc:19:1: note: in expansion of macro 'll' 19 | ll k; | ^~ a.cc: In function 'int main()': a.cc:15:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'? 15 | #define ll __int64 | ^~~~~~~ a.cc:41:9: note: in expansion of macro 'll' 41 | ll ans=0; | ^~ a.cc:46:44: error: expected ';' before 'tmp' 46 | ll tmp=0,we=0; | ^~~ a.cc:47:57: error: 'tmp' was not declared in this scope; did you mean 'tm'? 47 | rep(z,i)tmp+=t[0][z],we+=k+3; | ^~~ | tm a.cc:47:70: error: 'we' was not declared in this scope; did you mean 'w'? 47 | rep(z,i)tmp+=t[0][z],we+=k+3; | ^~ | w a.cc:48:57: error: 'tmp' was not declared in this scope; did you mean 'tm'? 48 | rep(z,j)tmp+=t[1][z],we+=k+2; | ^~~ | tm a.cc:48:70: error: 'we' was not declared in this scope; did you mean 'w'? 48 | rep(z,j)tmp+=t[1][z],we+=k+2; | ^~ | w a.cc:49:57: error: 'tmp' was not declared in this scope; did you mean 'tm'? 49 | rep(z,x)tmp+=t[2][z],we+=k+1; | ^~~ | tm a.cc:49:70: error: 'we' was not declared in this scope; did you mean 'w'? 49 | rep(z,x)tmp+=t[2][z],we+=k+1; | ^~ | w a.cc:50:57: error: 'tmp' was not declared in this scope; did you mean 'tm'? 50 | rep(z,y)tmp+=t[3][z],we+=k; | ^~~ | tm a.cc:50:70: error: 'we' was not declared in this scope; did you mean 'w'? 50 | rep(z,y)tmp+=t[3][z],we+=k; | ^~ | w a.cc:52:52: error: 'we' was not declared in this scope; did you mean 'w'? 52 | if(we<=m)ans=max(ans,tmp); | ^~ | w a.cc:52:58: error: 'ans' was not declared in this scope; did you mean 'abs'? 52 | if(we<=m)ans=max(ans,tmp); | ^~~ | abs a.cc:52:70: error: 'tmp' was not declared in this scope; did you mean 'tm'? 52 | if(we<=m)ans=max(ans,tmp); | ^~~ | tm a.cc:58:15: error: 'ans' was not declared in this scope; did you mean 'abs'? 58 | cout<<ans<<endl; | ^~~ | abs
s594529195
p03732
C++
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define INF (1<<30) #define INFLL (1ll<<60) typedef pair<ll, ll> P; #define MOD (1000000007ll) #define l_ength size void mul_mod(ll& a, ll b){ a *= b; a %= MOD; } int main(void){ int n,i,j,a[4],m[4]; ll w,v,ans=0ll,W,c[4],wsum,vsum; vector<ll> g[4]; cin >> n >> W; cin >> c[0] >> v; g[0].push_back(v); for(i=1; i<n; ++i){ cin >> w >> v; g[w-c[0]].push_back(v); } for(i=0; i<4; ++i){ c[i] = c[0]+i; g[i].push_back(0ll); m[i] = g[i].l_ength(); sort(g[i].begin(),g[i].end()); for(j=1; j<m[i]; j++){ g[i][j] += g[i][j-1]; } } ans = 0ll; for(a[0]=0; a[0]<m[0]; ++a[0]){ for(a[1]=0; a[1]<m[1]; ++a[1]){ for(a[2]=0; a[2]<m[2]; ++a[2]){ for(a[3]=0; a[3]<m[3]; ++a[3]){ wsum = 0ll; for(i=0; i<4; i++){ wsum += c[i]*a[i]; } if(wsum>W){ continue; } vsum = 0ll; for(i=0; i<4; i++){ vsum += g[a[i]]; } ans = max(ans,vsum); } } } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:49:54: error: no match for 'operator+=' (operand types are 'll' {aka 'long long int'} and 'std::vector<long long int>') 49 | vsum += g[a[i]]; | ~~~~~^~~~~~~~~~
s519539727
p03732
C++
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define INF (1<<30) #define INFLL (1ll<<60) typedef pair<ll, ll> P; #define MOD (1000000007ll) #define l_ength size void mul_mod(ll& a, ll b){ a *= b; a %= MOD; } int main(void){ int n,i,j,a[4],m[4]; ll w,v,ans=0ll,W,c[4],wsum,vsum; vector<ll> g[4]; cin >> n >> W; cin >> c[0] >> v; g[0].push_back(v); for(i=1; i<n; ++i){ cin >> w >> v; g[w-c[0]].push_back(v); } for(i=0; i<4; ++i){ c[i] = c[0]+i; g[i].push_back(0ll); m[i] = g[i].l_ength(); sort(g[i].begin(),g[i].end()); for(j=1; j<m[i]; j++){ g[i] += g[i-1]; } } ans = 0ll; for(a[0]=0; a[0]<m[0]; ++a[0]){ for(a[1]=0; a[1]<m[1]; ++a[1]){ for(a[2]=0; a[2]<m[2]; ++a[2]){ for(a[3]=0; a[3]<m[3]; ++a[3]){ wsum = 0ll; for(i=0; i<4; i++){ wsum += c[i]*a[i]; } if(wsum>W){ continue; } vsum = 0ll; for(i=0; i<4; i++){ vsum += g[a[i]]; } ans = max(ans,vsum); } } } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:32:30: error: no match for 'operator+=' (operand types are 'std::vector<long long int>' and 'std::vector<long long int>') 32 | g[i] += g[i-1]; | ~~~~~^~~~~~~~~ a.cc:49:54: error: no match for 'operator+=' (operand types are 'll' {aka 'long long int'} and 'std::vector<long long int>') 49 | vsum += g[a[i]]; | ~~~~~^~~~~~~~~~
s674363325
p03732
C++
#include "bits/stdc++.h" using namespace std; typedef long long ll; #define INF (1<<30) #define INFLL (1ll<<60) typedef pair<ll, ll> P; #define MOD (1000000007ll) #define l_ength size void mul_mod(ll& a, ll b){ a *= b; a %= MOD; } int main(void){ int n,i,j,a[4],m[4]; ll w,v,ans=0ll,W,c[4],wsum,vsum; vector<ll> g[4]; cin >> n >> W; cin >> c[0] >> v; g[0].push(v); for(i=1; i<n; ++i){ cin >> w >> v; g[w-c[0]].push(v); } for(i=0; i<4; ++i){ c[i] = c[0]+i; g[i].push_back(0ll); m[i] = g[i].l_ength(); sort(g[i].begin(),g[i].end()); for(j=1; j<m[i]; j++){ g[i] += g[i-1]; } } ans = 0ll; for(a[0]=0; a[0]<m[0]; ++a[0]){ for(a[1]=0; a[1]<m[1]; ++a[1]){ for(a[2]=0; a[2]<m[2]; ++a[2]){ for(a[3]=0; a[3]<m[3]; ++a[3]){ wsum = 0ll; for(i=0; i<4; i++){ wsum += c[i]*a[i]; } if(wsum>W){ continue; } vsum = 0ll; for(i=0; i<4; i++){ vsum += g[a[i]]; } ans = max(ans,vsum); } } } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:21:14: error: 'class std::vector<long long int>' has no member named 'push' 21 | g[0].push(v); | ^~~~ a.cc:24:27: error: 'class std::vector<long long int>' has no member named 'push' 24 | g[w-c[0]].push(v); | ^~~~ a.cc:32:30: error: no match for 'operator+=' (operand types are 'std::vector<long long int>' and 'std::vector<long long int>') 32 | g[i] += g[i-1]; | ~~~~~^~~~~~~~~ a.cc:49:54: error: no match for 'operator+=' (operand types are 'll' {aka 'long long int'} and 'std::vector<long long int>') 49 | vsum += g[a[i]]; | ~~~~~^~~~~~~~~~
s858477589
p03732
C++
#include <cassert> #include <cctype> #include <cerrno> #include <cfloat> #include <ciso646> #include <climits> #include <clocale> #include <cmath> #include <csetjmp> #include <csignal> #include <cstdarg> #include <cstddef> #include <cstdio> #include <cstdlib> #include <cstring> #include <ctime> /* //#if __cplusplus >= 201103L #include <ccomplex> #include <cfenv> #include <cinttypes> #include <cstdbool> #include <cstdint> #include <ctgmath> #include <cwchar> #include <cwctype> */ // C++ #include <algorithm> #include <bitset> #include <complex> #include <deque> #include <exception> #include <fstream> #include <functional> #include <iomanip> #include <ios> #include <iosfwd> #include <iostream> #include <istream> #include <iterator> #include <limits> #include <list> #include <locale> #include <map> #include <memory> #include <new> #include <numeric> #include <ostream> #include <queue> #include <set> #include <sstream> #include <stack> #include <stdexcept> #include <streambuf> #include <string> #include <typeinfo> #include <utility> #include <valarray> #include <vector> /* //#if __cplusplus >= 201103L #include <array> #include <chrono> #include <condition_variable> #include <forward_list> #include <future> #include <initializer_list> #include <mutex> #include <random> #include <ratio> #include <regex> #include <scoped_allocator> #include <system_error> #include <thread> #include <tuple> #include <typeindex> #include <type_traits> #include <unordered_map> #include <unordered_set> */ using namespace std; #define fi first #define se second #define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++) #define rep(i,n) repl(i,0,n) #define each(itr,v) for(auto itr:v) #define pb(s) push_back(s) #define mmax(x,y) (x>y?x:y) #define mmin(x,y) (x<y?x:y) #define maxch(x,y) x=mmax(x,y) #define minch(x,y) x=mmin(x,y) #define mp(a,b) make_pair(a,b) #define all(x) (x).begin(),(x).end() #define dbg(x) cout<<#x"="<<x<<endl #define uni(x) x.erase(unique(all(x)),x.end()) template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;} template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;} #define MAX(a, b) ((a) > (b) ? (a) : (b)) #define MIN(a, b) ((a) > (b) ? (b) : (a)) typedef long long ll; typedef unsigned long long ull; typedef pair<int, int> P; typedef pair<P, int> PPI; #define INF INT_MAX/3 #define MAX_N 1000 #define M_INF 1000000000 int n,m,v,i; void solve(){ cin.tie(0); ios::sync_with_stdio(false); cin>>n>>m; // ll cost[n+1][n+1]; // ll maxcost[n+1]; // bool used[n+1]; // fill(maxcost,maxcost+n,-INF); // fill(used,used+n,false); ll dp[n][n]; rep(i,n){ fill(dp[n],dp[n]+n,-M_INF+5); } rep(i,m){ int a,b,c; cin>>a>>b>>c; a--; b--; dp[a][b] = c; } rep(k,n){ rep(i,n){ rep(j,n){ if(dp[i][j] < dp[i][k] + dp[k][j]){ maxch(dp[i][j],dp[i][k] + dp[k][j]) } } } } cout<<dp[0][n-1]<<endl; // maxcost[0] = 0; // int res = 0; // while(true){ // int v = -1; // rep(u,n) { // if(!used[u] && (v == -1 || maxcost[u] > maxcost[v])) v = u; // } // // if( v == -1 ){ // cout<<"inf"<<endl; // break; // } // used[v] = true; // res += maxcost[v]; // // rep(u,n){ // if(maxcost[u] < cost[v][u]){ // maxcost[u] = cost[v][u]; // } // } // } // cout<<res<<endl; } int main(){ solve(); return 0; }
a.cc: In function 'void solve()': a.cc:138:9: error: expected ';' before '}' token 138 | } | ^
s952419834
p03732
C++
#include<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> #include<vector> #include<string> #include<sstream> #include<iomanip> #include<utility> #include<cmath> #include<set> #include<list> #include<queue> #include<stack> #include<deque> #include<map> #include<set> #include<cstring> #include<iterator> #include<bitset> using namespace std; struct edge {int /*from,*/to,cost;}; typedef long long ll; typedef pair<int,int> P; typedef pair<int,pair<int,int> > PP; typedef vector<int> VI; typedef vector<long long int> VL; typedef vector<edge> VE; static const int MOD = 1000000007; //static const int INF = 2147483647; //static const long long INF = 9223372000000000000; //static const long long INF = 9223372000000000000/2; //static const int INF = 1000010000; //int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0}; //int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0}; //int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0}; //int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0}; #define pb push_back #define mp make_pair #define fi first #define se second #define np next_permutation #define pq priority_queue #define UB upper_bound #define LB lower_bound #define all(x) (x).begin(),(x).end() #define SZ(a) int((a).size()) #define LEN(a) int((a).length()) #define MAX(a,b,c) max((a),max((b),(c))) #define MIN(a,b,c) min((a),min((b),(c))) #define SORT(c) sort((c).begin(),(c).end()) #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define REP(i,x) for(int i=0;i<(int)(x);i++) #define REP1(i,x) for(int i=1;i<=(int)(x);i++) #define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--) #define RREP1(i,x) for(int i=((int)(x));i>0;i--) #define int ll signed main(){ int N,W; scanf("%lld%lld",&N,&W); int m; VI w[4]; REP(i,N){ int a,b; scanf("%lld%lld",&a,&b); if(i==0) m = a; w[a-m].pb(b); } REP(i,4) SORT(w[i]),reverse(all(w[i])); REP(i,4) w[i].insert(w[i].begin(),0); REP(i,4) REP(j,SZ(w[i])-1) w[i][j+1] += w[i][j]; int ans = 0; REP(i,SZ(w[0])){ REP(j,SZ(w[1])){ REP(k,SZ(w[2])){ REP(l,SZ(w[3])){ if(m*i+(m+1)*j+(m+2)*k+(m+3)*l<=W){ ans = max(ans,w[0][i]+w[1][j]+w[2][k]+w[3][l]); } } } } } printf("%lld\n",ans); return 0; }
a.cc: In function 'int main()': a.cc:81:22: error: no matching function for call to 'max(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)' 81 | ans = max(ans,w[0][i]+w[1][j]+w[2][k]+w[3][l]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:81:22: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'}) 81 | ans = max(ans,w[0][i]+w[1][j]+w[2][k]+w[3][l]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:4: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:81:22: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 81 | ans = max(ans,w[0][i]+w[1][j]+w[2][k]+w[3][l]); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s177217642
p03732
C++
#include <iostream> #include <algorithm> #include <vector> using namespace std; int main(void) { int n, w; cin >> n >> w; vector<int> v1, v2, v3, v4; int minw, iniv; cin >> minw >> iniv; v1.push_back(iniv); for (int i = 1; i < n; i++) { int a, b; cin >> a >> b; if (a == minw) { v1.push_back(b); } else if (a == minw + 1) { v2.push_back(b); } else if (a == minw + 2) { v3.push_back(b); } else if (a == minw + 3) { v4.push_back(b); } } sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end()); sort(v3.begin(), v3.end()); sort(v4.begin(), v4.end()); vector<int> sum1(v1.size() + 1, 0), sum2(v2.size() + 1, 0), sum3(v3.size() + 1, 0), sum4(v4.size() + 1, 0); for (int i = 1; i <= v1.size(); i++) { sum1[i] = sum1[i - 1] + v1[i - 1]; } for (int i = 1; i <= v2.size(); i++) { sum2[i] = sum2[i - 1] + v2[i - 1]; } for (int i = 1; i <= v3.size(); i++) { sum3[i] = sum3[i - 1] + v3[i - 1]; } for (int i = 1; i <= v4.size(); i++) { sum4[i] = sum4[i - 1] + v4[i - 1]; } ll ans = 0; for (int i = 0; i <= v4.size(); i++) { int wnow = (minw + 3) * i; if (wnow > w) break; for (int j = 0; j <= v3.size(); j++) { wnow = (minw + 3) * i + (minw + 2) * j; if (wnow > w) break; for (int k = 0; k <= v2.size(); k++) { wnow = (minw + 3) * i + (minw + 2) * j + (minw + 1) * k; if (wnow > w) break; int l = min((w - wnow) / minw, (int)v1.size()); if (sum1[l] + sum2[k] + sum3[j] + sum4[i] > ans) ans = sum1[l] + sum2[k] + sum3[j] + sum4[i]; } } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:42:3: error: 'll' was not declared in this scope 42 | ll ans = 0; | ^~ a.cc:53:53: error: 'ans' was not declared in this scope; did you mean 'abs'? 53 | if (sum1[l] + sum2[k] + sum3[j] + sum4[i] > ans) ans = sum1[l] + sum2[k] + sum3[j] + sum4[i]; | ^~~ | abs a.cc:57:11: error: 'ans' was not declared in this scope; did you mean 'abs'? 57 | cout << ans << endl; | ^~~ | abs
s036522797
p03732
C++
#include <iostream> #include <vector> #include <algorithm> #include <map> #include <string> #include <iomanip> #include <cmath> #include <functional> using namespace std; using ll = long long; const ll INF = ((1LL << 60) - 1); int N, W, u, v, w0, a, b, c, d; vector<ll> w[4]; //ll memo[101][101][101][101]; // メモ化再帰 ll solve(ll price = 0, ll sum = 0, int i = 0, int j = 0, int k = 0, int l = 0) { //if (memo[i][j][k][l] != 0) return memo[i][j][k][l]; if (sum > W) return -INF; ll ret = 0; ret = max(ret, price); if (i != a) ret = max(ret, solve(price + w[0][i], sum + w0, i + 1, j, k, l)); if (j != b) ret = max(ret, solve(price + w[1][j], sum + w0 + 1, i, j + 1, k, l)); if (k != c) ret = max(ret, solve(price + w[2][k], sum + w0 + 2, i, j, k + 1, l)); if (l != d) ret = max(ret, solve(price + w[3][l], sum + w0 + 3, i, j, k, l + 1)); return memo[i][j][k][l] = ret; } int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> N >> W; for (int i = 0; i < N; ++i) { cin >> u >> v; if (i == 0) { w0 = u; w[0].push_back(v); } else { for (int i = 0; i < 4; ++i) { if (w0 + i == u) { w[i].push_back(v); break; } } } } for (int i = 0; i < 4; ++i) { sort(w[i].begin(), w[i].end(), greater<int>()); } a = w[0].size(); b = w[1].size(); c = w[2].size(); d = w[3].size(); ll ans = solve(); cout << ans << endl; return 0; }
a.cc: In function 'll solve(ll, ll, int, int, int, int)': a.cc:33:10: error: 'memo' was not declared in this scope 33 | return memo[i][j][k][l] = ret; | ^~~~
s867928774
p03732
C++
#include<iostream> #include<algorithm> #include<functional> #include <string> #include<iomanip> #include<cstdio> #include<math.h> #include<set> #include<stack> #include<queue> #include<cstring> #include<vector> typedef long long int ll; #define FOR(i,a,b) for(ll i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define EREP(i,n) for(int i=(n-1);i>=0;--i) #define D(n,retu) REP(i,n){cin>>retu[i];} #define mod 1000000007 #define MIN -93193111451418101 #define INF 931931114518101 using namespace std; typedef pair<ll, ll>P; template<typename T> void fill_all(T& arr, const T& v) { arr = v; } template<typename T, typename ARR> void fill_all(ARR& arr, const T& v) { for (auto& i : arr) { fill_all(i, v); } } #define MAX_NUM 50 long long comb[MAX_NUM + 1][MAX_NUM + 1]; ll par[100000], depth[100000]; static void calc_comb() { for (uint32_t i = 0; i <= MAX_NUM; i++) { for (uint32_t j = 0; j <= i; j++) { if ((j == 0) || (i == j)) { comb[i][j] = 1; } else { comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j]; } } } } #define yo 100001 //------------------変数-----------------------// ll d, n, t[300] = {}, dp[101][101][301][101] = {}, W; P p[101] = {}; vector<ll> zero, one, two, three; ll mini; //-------------------関数----------------------// ll DP(ll num, ll onenum, ll weight,ll tw) { if (num*mini + weight > W) { return -INF; } if (num == n) { return 0; } if (dp[num][onenum][weight][tw]>=0) { return dp[num][onenum][weight][tw]; } ll cnt = 0; for (ll izryt = 0; izryt < 4; izryt++) { // cout << izryt << endl; if (izryt == 0) { if (zero.size()) { ll hoge = zero.back(); zero.pop_back(); ll bwam = DP(num + 1, onenum , weight,tw) + hoge; cnt = max(cnt, bwam); zero.push_back(hoge); } } if (izryt == 1) { if (one.size()) { ll hoge = one.back(); one.pop_back(); ll bwam = DP(num + 1, onenum+1, weight + 1,tw) + hoge; cnt = max(cnt, bwam); one.push_back(hoge); } } if (izryt == 2) { if (two.size()) { ll hoge = two.back(); two.pop_back(); ll bwam = DP(num + 1, onenum, weight + 2,tw+1) + hoge; cnt = max(cnt, bwam); two.push_back(hoge); } } if (izryt == 3) { if (three.size()) { ll hoge = three.back(); three.pop_back(); ll bwam = DP(num + 1, onenum, weight + 3,tw) + hoge; cnt = max(cnt, bwam); three.push_back(hoge); } } } return dp[num][onenum][weight][tw] = cnt; } int main() { cin >> n >> W; fill_all(dp, (ll)-1); REP(i, n) { ll w, v; cin >> w >> v; p[i].first = w; p[i].second = v; } sort(p, p + n); mini = p[0].first; REP(i, n) { ll izryt = p[i].first - mini; if (izryt == 0) { zero.push_back(p[i].second); } if (izryt == 1) { one.push_back(p[i].second); } if (izryt == 2) { two.push_back(p[i].second); } if (izryt == 3) { three.push_back(p[i].second); } } cout << DP(0, 0, 0, 0) << endl; return 0; }
a.cc: In function 'void calc_comb()': a.cc:37:14: error: 'uint32_t' was not declared in this scope 37 | for (uint32_t i = 0; i <= MAX_NUM; i++) { | ^~~~~~~~ a.cc:12:1: note: 'uint32_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>' 11 | #include<cstring> +++ |+#include <cstdint> 12 | #include<vector> a.cc:37:30: error: 'i' was not declared in this scope 37 | for (uint32_t i = 0; i <= MAX_NUM; i++) { | ^ a.cc:38:30: error: expected ';' before 'j' 38 | for (uint32_t j = 0; j <= i; j++) { | ^~ | ; a.cc:38:38: error: 'j' was not declared in this scope; did you mean 'jn'? 38 | for (uint32_t j = 0; j <= i; j++) { | ^ | jn
s460243416
p03732
C++
#include <iostream> using namespace std; using ll = long long; ll max(ll x,ll y){ if(x>y){ return x; }else{ return y; } } int main(){ ll dp[101][11]; ll N,W; ll w[101]={},v[101]={}; ll w_1; cin >> N >> W; for(int i=1;i<=N;i++){ cin >> w[i] >> v[i]; if(i==1){ //w[i] 0<=...<=3 w_1=w[1]-1; w[1]=1; }else{ w[i]=w[i]-w_1; } } for(int i=0;i<101;i++){ for(int j=0;j<11;j++){ dp[i][j]=0; } } bool check[5]={}; check[0]=true; for(int i=0;i<N;i++){ for(int j=0;j<11;j++){ if(check[j]){ dp[i+1][j]=max(dp[i+1][j],dp[i][j]); if(j+w[i+1]<=W-(w_1+1&&j+w[i+1]<11)){ dp[i+1][j+w[i+1]]=max(dp[i+1][j+w[i+1]],dp[i][j]+v[i+1]); check[j+w[i+1]]=true; } } } } ll answer=0; for(int i=0;i<11;i++){ answer = max(answer,dp[N][i]); } cout << answer << endl; return 0; } int main(){ ll dp[101][11]; ll N,W; ll w[101]={},v[101]={}; ll w_1; cin >> N >> W; for(int i=1;i<=N;i++){ cin >> w[i] >> v[i]; if(i==1){ //w[i] 0<=...<=3 w_1=w[1]-1; w[1]=1; }else{ w[i]=w[i]-w_1; } } for(int i=0;i<101;i++){ for(int j=0;j<11;j++){ dp[i][j]=0; } } bool check[5]={}; check[0]=true; for(int i=0;i<N;i++){ for(int j=0;j<11;j++){ if(check[j]){ dp[i+1][j]=max(dp[i+1][j],dp[i][j]); if(j+w[i+1]<=W-(w_1+1)){ dp[i+1][j+w[i+1]]=max(dp[i+1][j+w[i+1]],dp[i][j]+v[i+1]); check[j+w[i+1]]=true; } } } } ll answer=0; for(int i=0;i<11;i++){ answer = max(answer,dp[N][i]); } cout << answer << endl; return 0; }
a.cc:65:5: error: redefinition of 'int main()' 65 | int main(){ | ^~~~ a.cc:14:5: note: 'int main()' previously defined here 14 | int main(){ | ^~~~
s968073200
p03732
C++
#include <iostream> #include <fstream> #include <string> #include <cmath> #include <cstdlib> #include <ctime> #include <vector> #include <algorithm> #include <numeric> #include <map> #include <functional> using namespace std; using ll = long long; int main() { int N; ll W,w0,w,v,n0,n1,n2,n3,Wsum,Vsum; cin >> N >> W; vector<pair<ll, ll> > pairs0, pairs1, pairs2, pairs3; vector<ll> v0, v1, v2, v3, Vmax; cin >> w0 >> v; pairs0.push_back(make_pair(w0, v)); for (int i = 1; i < N; i++) { cin >> w >> v; if (w == w0) pairs0.push_back(make_pair(w, v)); if (w == w0 + 1) pairs1.push_back(make_pair(w, v)); if (w == w0 + 2) pairs2.push_back(make_pair(w, v)); if (w == w0 + 3) pairs3.push_back(make_pair(w, v)); } if (w0 > W) { cout << 0 << endl; return 0; } sort(pairs0.begin(), pairs0.end(), greater<ll>()); sort(pairs1.begin(), pairs1.end(), greater<ll>()); sort(pairs2.begin(), pairs2.end(), greater<ll>()); sort(pairs3.begin(), pairs3.end(), greater<ll>()); n0 = min(W / w0, (ll)pairs0.size()); n1 = min(W / (w0 + 1), (ll)pairs1.size()); n2 = min(W / (w0 + 2), (ll)pairs2.size()); n3 = min(W / (w0 + 3), (ll)pairs3.size()); for (ll i = 0; i < n0; i++) { v0.push_back(pairs0[i].second); } for (ll i = 0; i < n1; i++) { v1.push_back(pairs1[i].second); } for (ll i = 0; i < n2; i++) { v2.push_back(pairs2[i].second); } for (ll i = 0; i < n3; i++) { v3.push_back(pairs3[i].second); } for (ll i = 0; i < n0 + 1; i++) { for (ll j = 0; j < n1 + 1; j++) { for (ll k = 0; k < n2 + 1; k++) { for (ll l = 0; l < n3 + 1; l++) { Wsum = i*w0 + j*(w0 + 1) + k*(w0 + 2) + l*(w0 + 3); if (Wsum <= W) { Vsum = 0; cout << i << "," << j << "," << k << "," << l << endl; if (i != 0) Vsum += accumulate(v0.begin(), v0.begin() + i, 0); if (j != 0) Vsum += accumulate(v1.begin(), v1.begin() + j, 0); if (k != 0) Vsum += accumulate(v2.begin(), v2.begin() + k, 0); if (l != 0) Vsum += accumulate(v3.begin(), v3.begin() + l, 0); Vmax.push_back(Vsum); } } } } } sort(Vmax.begin(), Vmax.end(), greater<ll>()); cout << Vmax[0] << endl; return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Iterator2 = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Compare = std::greater<long long int>]': /usr/include/c++/14/bits/stl_algo.h:1777:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]' 1777 | if (__comp(__i, __first)) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Compare = greater<long long int>]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:37:6: required from here 37 | sort(pairs0.begin(), pairs0.end(), greater<ll>()); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:158:30: error: no match for call to '(std::greater<long long int>) (std::pair<long long int, long long int>&, std::pair<long long int, long long int>&)' 158 | { return bool(_M_comp(*__it1, *__it2)); } | ~~~~~~~^~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:49: /usr/include/c++/14/bits/stl_function.h:394:7: note: candidate: 'constexpr bool std::greater<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = long long int]' 394 | operator()(const _Tp& __x, const _Tp& __y) const | ^~~~~~~~ /usr/include/c++/14/bits/stl_function.h:394:29: note: no known conversion for argument 1 from 'std::pair<long long int, long long int>' to 'const long long int&' 394 | operator()(const _Tp& __x, const _Tp& __y) const | ~~~~~~~~~~~^~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = std::pair<long long int, long long int>; _Iterator = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Compare = std::greater<long long int>]': /usr/include/c++/14/bits/stl_algo.h:1757:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Compare = __gnu_cxx::__ops::_Val_comp_iter<greater<long long int> >]' 1757 | while (__comp(__val, __next)) | ~~~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1785:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]' 1785 | std::__unguarded_linear_insert(__i, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ 1786 | __gnu_cxx::__ops::__val_comp_iter(__comp)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4805:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Compare = greater<long long int>]' 4805 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_comp_iter(__comp)); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:37:6: required from here 37 | sort(pairs0.begin(), pairs0.end(), greater<ll>()); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:240:30: error: no match for call to '(std::greater<long long int>) (std::pair<long long int, long long int>&, std::pair<long long int, long long int>&)' 240 | { return bool(_M_comp(__val, *__it)); } | ~~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_function.h:394:7: note: candidate: 'constexpr bool std::greater<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = long long int]' 394 | operator()(const _Tp& __x, const _Tp& __y) const | ^~~~~~~~ /usr/include/c++/14/bits/stl_function.h:394:29: note: no known conversion for argument 1 from 'std::pair<long long int, long long int>' to 'const long long int&' 394 | operator()(const _Tp& __x, const _Tp& __y) const | ~~~~~~~~~~~^~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<std::pair<long long int, long long int>*, std::vector<std::pair<long long int, long long int> > >; _Value = std::pair<long long int, long long int>; _Compare = std::greater<long long int>]': /usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Distance = long int; _Tp = pair<long long int, long long int>; _Compare = __gnu_cxx::__ops::_Iter_comp_val<greater<long long int> >]' 140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:247:23: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Distance = long int; _Tp = pair<long long int, long long int>; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]' 247 | std::__push_heap(__first, __holeIndex, __topIndex, | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 248 | _GLIBCXX_MOVE(__value), __cmp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:356:22: required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<pair<long long int, long long int>*, vector<pair<long long int, long long int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<greater<long long int> >]' 356 | std::__adjust_heap(__first, __parent, __len, _GLIBCXX_MOVE(__value), | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 357 | __comp); | ~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1593:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterat
s061010767
p03732
C++
#include <iostream> using namespace std; typedef long long ll; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) ll v[4][101]; int c[4]; int main() { int n,w; cin>>n>>w; int w0; cin >> w0 >> v[0][++c[0]]; FOR(i,1,n){ int r; cin >> r; cin >> v[r-w0][++c[r-w0]]; } REP(i,4){ sort(v[i] + 1, v[i] + 1 + c[i], greater<ll>()); REP(j,c[i])v[i][j+1]+=v[i][j]; c[i]++; } ll ans = 0; REP(i,c[0])REP(j,c[1])REP(k, c[2])REP(l,c[3]){ ll a = (ll)v[0][i] + v[1][j] + v[2][k] + v[3][l]; ll s = (ll)w0 * (i+j+k+l) + j + k*2 + l*3; if(s<=w)ans = max(ans, a); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:20:17: error: 'sort' was not declared in this scope; did you mean 'short'? 20 | sort(v[i] + 1, v[i] + 1 + c[i], greater<ll>()); | ^~~~ | short
s036907033
p03732
C++
// knapsack.cpp : コンソール アプリケーションのエントリ ポイントを定義します。 // #include "stdafx.h" #include <iostream> #include <string> #include <map> #include <vector> #include <algorithm> using namespace std; #define REP(i,k,n) for(int i=k;i<n;i++) #define rep(i,n) for(int i=0;i<n;i++) #define all(v) v.begin(),v.end() #define INF 1<<30 #define mp make_pair #define pb push_back typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vp; typedef long long ll; ll dp[100][100]; ll n; ll w[100], v[100]; ll knapsack(int p, int W){ ll ans = 0; for (int i = n - 1; i >= 0; i--){ rep(j, W + 1){ if (i == n - 1){ dp[i][j] = j >= w[i] ? v[i] : 0; } else{ if (j < w[i]) dp[i][j] = dp[i + 1][j]; else dp[i][j] = max(dp[i + 1][j - w[i]] + v[i], dp[i + 1][j]); } ans = max(ans, dp[i][j]); } //cout << "@ ans:" << ans<<endl; } //cout << "@ dp[2][2]:" << dp[2][2] << endl; //cout << "@ dp[2][2-w[1]]+v[1]:" << dp[2][2-w[1]]+v[1] << endl; //cout << "@ dp[1][3]:" << dp[1][3] << endl; //cout << "@ v[1]:" << v[1] << endl; return ans; } int main(){ ll W; cin >> n >> W; rep(i, n){ cin >> w[i] >> v[i]; } cout << knapsack(0, W) << endl; return 0; }
a.cc:4:10: fatal error: stdafx.h: No such file or directory 4 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s239601897
p03732
C++
#include <iostream> #include <string> #include <map> #include <vector> #include <algorithm> using namespace std; #define REP(i,k,n) for(int i=k;i<n;i++) #define rep(i,n) for(int i=0;i<n;i++) #define all(v) v.begin(),v.end() #define INF 1<<30 #define mp make_pair #define pb push_back typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vp; typedef long long ll; ll dp[100][100]; ll n; ll w[100], v[100]; ll knapsack(int p, int W){ ll ans = 0; for (int i = n - 1; i >= 0; i--){ rep(j, W + 1){ if (i == n - 1){ dp[i][j] = j >= w[i] ? v[i] : 0; } else{ if (j < w[i]) dp[i][j] = dp[i + 1][j]; else dp[i][j] = max(dp[i + 1][j - w[i]] + v[i], dp[i + 1][j]); } ans = max(ans, dp[i][j]); } //cout << "@ ans:" << ans<<endl; } //cout << "@ dp[2][2]:" << dp[2][2] << endl; //cout << "@ dp[2][2-w[1]]+v[1]:" << dp[2][2-w[1]]+v[1] << endl; //cout << "@ dp[1][3]:" << dp[1][3] << endl; //cout << "@ v[1]:" << v[1] << endl; return ans; } int main(){ memset(dp, 0, sizeof(dp)); ll W; cin >> n >> W; rep(i, n){ cin >> w[i] >> v[i]; } cout << knapsack(0, W) << endl; return 0; }
a.cc: In function 'int main()': a.cc:49:9: error: 'memset' was not declared in this scope 49 | memset(dp, 0, sizeof(dp)); | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include <algorithm> +++ |+#include <cstring> 6 |
s275129290
p03732
C++
// knapsack.cpp : コンソール アプリケーションのエントリ ポイントを定義します。 // #include "stdafx.h" #include <iostream> #include <string> #include <map> #include <vector> #include <algorithm> using namespace std; #define REP(i,k,n) for(int i=k;i<n;i++) #define rep(i,n) for(int i=0;i<n;i++) #define all(v) v.begin(),v.end() #define INF 1<<30 #define mp make_pair #define pb push_back typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vp; typedef long long ll; ll dp[100][100]; ll n; ll w[100], v[100]; ll knapsack(int p, int W){ ll ans = 0; for (int i = n - 1; i >= 0; i--){ rep(j, W + 1){ if (i == n - 1){ dp[i][j] = j >= w[i] ? v[i] : 0; } else{ if (j < w[i]) dp[i][j] = dp[i + 1][j]; else dp[i][j] = max(dp[i + 1][j - w[i]] + v[i], dp[i + 1][j]); } ans = max(ans, dp[i][j]); } //cout << "@ ans:" << ans<<endl; } //cout << "@ dp[2][2]:" << dp[2][2] << endl; //cout << "@ dp[2][2-w[1]]+v[1]:" << dp[2][2-w[1]]+v[1] << endl; //cout << "@ dp[1][3]:" << dp[1][3] << endl; //cout << "@ v[1]:" << v[1] << endl; return ans; } int main(){ memset(dp, 0, sizeof(dp)); ll W; cin >> n >> W; rep(i, n){ cin >> w[i] >> v[i]; } cout << knapsack(0, W) << endl; return 0; }
a.cc:4:10: fatal error: stdafx.h: No such file or directory 4 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s001462924
p03732
C++
#Simple Knapsack N,W = list(map(int, input().split())) w = [] v = [] for i in range(N): wi,vi = list(map(int, input().split())) w.append(wi) v.append(vi) #メモ化再帰 dp = [[-1]*(W+1) for i in range(N+1)] def rec(i, j): if dp[i][j] != -1: return dp[i][j] if i == N: res = 0 elif j < w[i]: res = rec(i + 1, j) else: res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]) dp[i][j] = res return res print(rec(0, W))
a.cc:1:2: error: invalid preprocessing directive #Simple 1 | #Simple Knapsack | ^~~~~~ a.cc:12:2: error: invalid preprocessing directive #\U000030e1\U000030e2\U00005316\U0000518d\U00005e30 12 | #メモ化再帰 | ^~~~~~~~~~ a.cc:3:1: error: 'N' does not name a type 3 | N,W = list(map(int, input().split())) | ^
s260699261
p03732
C++
#include <bits/stdc++.h> // #include "ane.cpp" const int INF = 1e9; const long long INFLL = 1e18; const int NMAX = 120; const int MMAX = 100005; const int KMAX = 1005; const int MOD = 1e9 + 7; using namespace std; // comment to disable debug functions // #define DEBUG // frequently used macros #if __cplusplus >= 201103L #define ALL(v) begin(v),end(v) #define SORT(v) sort(begin(v), end(v)) #define FIND(v,x) find(begin(v), end(v), (x)) #else #define ALL(v) (v).begin(),(v).end() #define SORT(v) sort(v.begin(), v.end()) #define FIND(v,x) find(v.begin(), v.end(), (x)) #endif #define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \ memset((from), 0, sizeof(from)); } while(0) #ifdef DEBUG #define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0) #else #define DUMP(x) do{}while(0) #endif // frequent used aliases typedef long long ll; typedef pair<int, int> p; typedef pair<ll, int> lp; typedef pair<ll, ll> llp; typedef vector<int> vec; typedef vector<ll> vecll; typedef vector<vec> mat; typedef vector<vecll> matll; // frequently used constants static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1}; static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1}; // frequently used structs struct edge{ int to,cost; }; // printf for debug #ifndef DEBUG void debug(const char* format, ...){} #else void debug(const char* format, ...){ va_list arg; va_start(arg, format); vprintf(format, arg); va_end(arg); } #endif // dump vector #ifdef DEBUG #define DUMPV(v, c) do{ \ printf("%s: ", #v); \ for (int i = 0; i < (c); ++i) \ { \ cout << (v)[i] << " "; \ } \ cout << endl; \ } while(0) #else #define DUMPV(v,c) #endif // std::fill of multi dimensions template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ std::fill( (T*)array, (T*)(array+N), val ); } // binary search ll BSearch(ll _begin, ll _end, bool (*f)(int)){ ll mid; while(_end - _begin > 1LL) { mid = (_begin + _end) / 2LL; if(f(mid)) { debug("BSearch: f(%d) == true\n", mid); _end = mid; } else { debug("BSearch: f(%d) == false\n", mid); _begin = mid; } } return _end; } ll N,M,K,A[NMAX],B[NMAX],C,D,E; ll dp[NMAX][3 * NMAX][NMAX]; string S; vec v; ll ans = 0; void solve(){ // main algorithm dp[0][0][0] = 0; for (ll i = 0; i < N; ++i) { for (ll j = 0; j <= i * 3; ++j) { for (ll k = 0; k <= i; ++k) { if (dp[i][j][k] != -1) { dp[i+1][j][k] = max(dp[i+1][j][k], dp[i][j][k]); ll jj = j + A[i] - A[0]; dp[i+1][jj][k+1] = max(dp[i+1][jj][k+1], dp[i][j][k] + B[i]); } } } } for (ll i = 0; i <= N; ++i) { for (ll j = 0; j <= M ― A[0] * i; ++j) { // if(j + A[0] * i > M) continue; ans = max(ans, dp[N][j][i]); } } } void debug(){ // output debug information for (int i = 0; i <= N; ++i) { DUMP(i); for (int j = 0; j <= 3 * i; ++j) { for (int k = 0; k <= i; ++k) { cout << dp[i][j][k] << " "; } cout << endl; } } } void answer(){ // output answer cout << ans << endl; } int main(int argc, char const *argv[]) { // operate inputs Fill(dp, -1); cin >> N >> M; for (int i = 0; i < N; ++i) { scanf("%lld%lld", &A[i], &B[i]); } solve(); #ifdef DEBUG debug(); #endif answer(); return 0; }
a.cc:133:27: error: extended character ― is not valid in an identifier 133 | for (ll j = 0; j <= M ― A[0] * i; ++j) | ^ a.cc: In function 'void solve()': a.cc:133:26: error: expected ';' before '\U00002015' 133 | for (ll j = 0; j <= M ― A[0] * i; ++j) | ^~ | ; a.cc:133:27: error: '\U00002015' was not declared in this scope 133 | for (ll j = 0; j <= M ― A[0] * i; ++j) | ^ a.cc:133:28: error: expected ')' before 'A' 133 | for (ll j = 0; j <= M ― A[0] * i; ++j) | ~ ^~ | ) a.cc:133:41: error: 'j' was not declared in this scope 133 | for (ll j = 0; j <= M ― A[0] * i; ++j) | ^
s686126118
p03732
C++
4 6 2 1 3 7 4 10 3 6
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 4 6 | ^
s611928011
p03732
Java
import java.util.ArrayList; import java.util.Comparator; import java.util.Scanner; public class Main2 { public static void main(String[] args) { new Main2().solve(); } static int N,W; static int w0; static ArrayList<Integer>[] v=new ArrayList[4]; static void solve(){ Scanner sc = new Scanner(System.in); N = sc.nextInt(); W = sc.nextInt(); for (int i = 0; i < v.length; i++) { v[i]=new ArrayList<Integer>(N); } w0=sc.nextInt(); v[0].add(sc.nextInt()); for(int i=1;i<N;i++){ int w=sc.nextInt(); v[w-w0].add(sc.nextInt()); } for(int i=0;i<v.length;i++){ v[i].sort(Comparator.reverseOrder()); } System.out.println(solve2(0,N,0)); } static int solve2(int startIndex,int numLeft,int totalW){ if(startIndex>=v.length){ return 0; } int vi=0; int wi=totalW; int max_v=0; for(int n=0;n<=numLeft && n<=v[startIndex].size();n++){ if(n>=1){ vi+=v[startIndex].get(n-1); wi+=w0+startIndex; } if(wi>W)break; max_v=Integer.max(max_v, vi+solve2(startIndex+1,numLeft-n,wi)); } return max_v; } }
Main.java:5: error: class Main2 is public, should be declared in a file named Main2.java public class Main2 { ^ Note: Main.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 1 error
s678063256
p03732
C
#include <stdio.h> #define ll long long int ll max(ll a, ll b){ return a > b ? a : b; } int main(){ llt N, W, i, j, w[101], v[101], C[101][10000000001]; scanf("%lld%lld", &N, &W); for(i = 1; i <= N; i++){ scanf("%lld%lld", &w[i], &v[i]); } for(i = 1; i <= N; i++) C[i][0] = 0; for(i = 1; i <= W; i++) C[0][i] = 0; for(i = 1; i <= N; i++){ for(j = 1; j <= W; j++){ if(j < w[i]) C[i][j] = C[i-1][j]; else C[i][j] = max(C[i-1][j], C[i - 1][j - w[i]] + v[i]); } } printf("%lld\n", C[N][W]); return 0; }
main.c: In function 'main': main.c:9:9: error: unknown type name 'llt'; did you mean 'll'? 9 | llt N, W, i, j, w[101], v[101], C[101][10000000001]; | ^~~ | ll
s006944341
p03732
C++
#include <iostream> #include <algorithm> using namespace std; int main(){ int N, W; cin >> N >> W; int w[N], v[N]; for(int i = 0; i < N; ++i){ cin >> w[i] >> v[i]; } int dp[N + 100][N + 100]; for(int i = N - 1; i >= 0; --i){ for(int j = 0; j <= W; ++j){ if(i == N - 1){ dp[N - 1][j] = max(0, v[N - 1]) } else if(j < w[i]) dp[i][j] = dp[i + 1][j]; else dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]); } } cout << dp[0][W] << endl; return 0; }
a.cc: In function 'int main()': a.cc:16:40: error: expected ';' before '}' token 16 | dp[N - 1][j] = max(0, v[N - 1]) | ^ | ; 17 | } | ~
s889043700
p03732
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; int N, W; int w, w0, v; vector<vector<int> > vv(4); int value(int I, int J, int K, int L) { int result = 0; for (int i = 0; i < I; i++) result += -vv[0][i]; for (int j = 0; j < J; j++) result += -vv[1][j]; for (int k = 0; k < K; k++) result += -vv[2][k]; for (int l = 0; l < L; l++) result += -vv[3][l]; return result; } int main() { // 入力 cin >> N >> W; cin >> w0 >> v; vv[0].push_back(-v); for (int i = 1; i < N; i++) { cin >> w >> v; vv[w - w0].push_back(-v); } for (int i = 0; i < 4; i++) { sort(vv[i].begin(), vv[i].end()); }a int ans = 0; for (int i = 0; i <= vv[0].size(); i++) { for (int j = 0; j <= vv[1].size(); j++) { for (int k = 0; k <= vv[2].size(); k++) { for (int l = 0; l <= vv[3].size(); l++) { if (i * w0 + j * (w0 + 1) + k * (w0 + 2) + l * (w0 + 3) > W) continue; ans = max(ans, value(i, j, k, l)); } } } } // 解答 cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:31:4: error: 'a' was not declared in this scope 31 | }a | ^ a.cc:38:11: error: 'ans' was not declared in this scope; did you mean 'abs'? 38 | ans = max(ans, value(i, j, k, l)); | ^~~ | abs a.cc:44:11: error: 'ans' was not declared in this scope; did you mean 'abs'? 44 | cout << ans << endl; | ^~~ | abs
s689433986
p03732
Java
import java.io.PrintStream; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Queue; import java.util.Scanner; import java.util.Set; public class Main { static boolean debug = true; static Scanner sc = new Scanner(System.in); static long max = Long.MIN_VALUE; public static void main(String[] args) throws Exception { int N = 0, W = 0; N = sc.nextInt(); W = sc.nextInt(); try{ int[][] goods = new int[N][2]; for (int i = 0; i < goods.length; i++) { goods[i][0] = sc.nextInt(); goods[i][1] = sc.nextInt(); } }catch(Throwable e){ System.out.println(); } int[][] dp = new int[W + 1][goods.length]; for (int i = 0; i < W + 1; i++) { for (int j = 0; j < goods.length; j++) { if (i < goods[j][0]) { if (j == 0) dp[i][j] = 0; else dp[i][j] = dp[i][j - 1]; } else { if (j == 0) dp[i][j] = goods[j][1]; else dp[i][j] = Math.max(dp[i][j - 1], dp[i - goods[j][0]][j - 1] + goods[j][1]); } } } System.out.println(dp[W][goods.length - 1]); } private static void print(String string) { // TODO Auto-generated method stub if (debug) System.out.println(string); } private static void print(int[] data) { if (debug) { for (int i = 0; i < data.length; i++) System.out.println(i + ":" + data[i]); } } private static void print(String[] data) { if (debug) { for (int i = 0; i < data.length; i++) System.out.println(i + ":" + data[i]); } } private static void print(char[] data) { if (debug) { for (int i = 0; i < data.length; i++) System.out.println(i + ":" + data[i]); } } private static void print(double[] data) { if (debug) { for (int i = 0; i < data.length; i++) System.out.println(i + ":" + data[i]); } } private static void print(int[][] data) { if (debug) { for (int i = 0; i < data.length; i++) { for (int j = 0; j < data[0].length; j++) { System.out.print(data[i][j] + " "); } System.out.println(); } } } private static void print(char[][] data) { if (debug) { for (int i = 0; i < data.length; i++) { for (int j = 0; j < data[0].length; j++) { System.out.print(i + " " + j + ":" + data[i][j] + " "); } System.out.println(); } } } private static void print(String[][] data) { if (debug) { for (int i = 0; i < data.length; i++) { for (int j = 0; j < data[0].length; j++) { System.out.print(i + " " + j + ":" + data[i][j] + " "); } System.out.println(); } } } private static void print(double[][] data) { if (debug) { for (int i = 0; i < data[0].length; i++) { for (int j = 0; j < data.length; j++) { System.out.print(i + " " + j + ":" + data[i][j] + " "); } System.out.println(); } } } public static void inPutData(char[][] c) { for (int i = 0; i < c.length; i++) { c[i] = sc.nextLine().toCharArray(); } } }
Main.java:35: error: cannot find symbol int[][] dp = new int[W + 1][goods.length]; ^ symbol: variable goods location: class Main Main.java:38: error: cannot find symbol for (int j = 0; j < goods.length; j++) { ^ symbol: variable goods location: class Main Main.java:39: error: cannot find symbol if (i < goods[j][0]) { ^ symbol: variable goods location: class Main Main.java:46: error: cannot find symbol dp[i][j] = goods[j][1]; ^ symbol: variable goods location: class Main Main.java:48: error: cannot find symbol dp[i][j] = Math.max(dp[i][j - 1], dp[i - goods[j][0]][j - 1] + goods[j][1]); ^ symbol: variable goods location: class Main Main.java:48: error: cannot find symbol dp[i][j] = Math.max(dp[i][j - 1], dp[i - goods[j][0]][j - 1] + goods[j][1]); ^ symbol: variable goods location: class Main Main.java:52: error: cannot find symbol System.out.println(dp[W][goods.length - 1]); ^ symbol: variable goods location: class Main 7 errors
s969126692
p03732
C++
#include<iostream> #include<string> #include<queue> #include<vector> using namespace std; typedef struct data{ long long int w,v; long long double p; }Data; void swap(Data *a,Data *b){ Data tmp=*a;*a=*b;*b=tmp; } int main(){ int N,ans=0; long long int W; cin>>N>>W; vector<Data> d(N); for(int i=0;i<N;i++){ cin>>d[i].w>>d[i].v; d[i].p=d[i].v / d[i].w; } for(int i=0;i<N;i++){ for(int j=i;j<N;j++){ if((d[i]).p<(d[j]).p)swap(&d[i],&d[j]); } } for(int i=0;i<N;i++){ if(W>=(d[i]).w){ W-=(d[i]).w;ans+=d[i].v; } if(W<=0)break; } cout<<ans<<endl; return 0; }
a.cc:9:8: error: 'long long' specified with 'double' 9 | long long double p; | ^~~~
s906018639
p03732
C++
#include <iostream> #include <cstdio> #include <vector> #include <queue> #include <algorithm> #define max(a,b) ((a)<(b)?(b):(a)) #define min(a,b) ((a)>(b)?(b):(a)) using namespace std; #define int long int main() { int N, W; cin >> N >> W; int w0, v0; int w[4] = {}; vector<int> v[4]; cin >> w0 >> v0; w[0]++; v[0].push_back(v0); for (int i = 1; i < N; i++) { int tw, tv; cin >> tw >> tv; w[tw - w0]++; v[tw - w0].push_back(tv); } for (int i = 0; i < 4; i++) { sort(v[i].rbegin(), v[i].rend()); } int ans = 0; for (int i = 0; i < w[0]+1; i++) { if (w0*i > W) break; for (int j = 0; j < w[1]+1; j++) { if (w0*(i + j) + j > W) break; for (int k = 0; k < w[2]+1; k++) { if (w0*(i + j + k) + j + 2 * k > W) break; int l = min((W - w0*(i + j + k) + j + 2 * k) / (w0 + 3), w[3]); int vsum = 0; for (int a = 0; a < i; a++) vsum += v[0][a]; for (int a = 0; a < j; a++) vsum += v[1][a]; for (int a = 0; a < k; a++) vsum += v[2][a]; for (int a = 0; a < l; a++) vsum += v[3][a]; ans = max(ans, vsum); } } } cout << ans << endl; return 0; }
cc1plus: error: '::main' must return 'int'
s953822598
p03732
C++
#include <iostream> #include <cstdio> #include <vector> #include <queue> #include <algorithm> #define max(a,b) ((a)<(b)?(b):(a)) #define min(a,b) ((a)>(b)?(b):(a)) using namespace std; #define int long int main() { int N, W; cin >> N >> W; int w0, v0; int w[4] = {}; vector<int> v[4]; cin >> w0 >> v0; w[0]++; v[0].push_back(v0); for (int i = 1; i < N; i++) { int tw, tv; cin >> tw >> tv; w[tw - w0]++; v[tw - w0].push_back(tv); } for (int i = 0; i < 4; i++) { sort(v[i].rbegin(), v[i].rend()); } int ans = 0; for (int i = 0; i < w[0]+1; i++) { if (w0*i > W) break; for (int j = 0; j < w[1]+1; j++) { if (w0*(i + j) + j > W) break; for (int k = 0; k < w[2]+1; k++) { if (w0*(i + j + k) + j + 2 * k > W) break; int l = min((W - w0*(i + j + k) + j + 2 * k) / (w0 + 3), w[3]); int vsum = 0; for (int a = 0; a < i; a++) vsum += v[0][a]; for (int a = 0; a < j; a++) vsum += v[1][a]; for (int a = 0; a < k; a++) vsum += v[2][a]; for (int a = 0; a < l; a++) vsum += v[3][a]; ans = max(ans, vsum); } } } cout << ans << endl; return 0; }
cc1plus: error: '::main' must return 'int'
s717579757
p03732
C++
#include <iostream> typedef long long LL; using namespace std; int main(int argc, char* argv[]) { int N; LL W; cin>>N>>W; LL **d = new LL*[N+1]; LL *v = new LL[N]; LL *w = new LL[N]; LL i,j; for (i=0;i<N;i++){ cin>>w[i]>>v[i]; } for (i=0;i<=N;i++){ d[i] = new LL[(LL)(W+1)]; memset(d[i],0,(W+1)*sizeof(LL)); } //ダイナミック計画法で解を求める for (i=1;i<=N;++i){ for (j=0;j<=W;++j){ d[i][j]=d[i-1][j]; if (j>=w[i-1]){ d[i][j] = max(d[i][j],d[i-1][j-w[i-1]]+v[i-1]); } } } cout<<d[N][W]<<endl; for (i=0;i<N;i++){ delete d[i]; } delete d; delete v,w; return 0; }
a.cc: In function 'int main(int, char**)': a.cc:18:17: error: 'memset' was not declared in this scope 18 | memset(d[i],0,(W+1)*sizeof(LL)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | typedef long long LL;
s365447061
p03732
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; using ll = long long; // ABC060D Simple Knapsack ll solve(int N, int W, vector<ll> &ws, vector<ll> &vs); int main() { ios::sync_with_stdio(false); int N, W; vector<ll> ws(100, 0); vector<ll> vs(100, 0); cin >> N >> W; for (int i = 0; i < N; ++i) cin >> ws[i] >> vs[i]; cout << solve(N, W, ws, vs) << endl; return 0; } ll solve(int N, int W, vector<ll> &ws, vector<ll> &vs) { auto min_w = ws[0]; vector<vector<ll>> vv(4, vector<ll>(0)); for (int i = 0; i < N; ++i) vv[ws[i] - min_w].push_back(vs[i]); for (int i = 0; i < 4; ++i) sort(vv[i].begin(), vv[i].end()); vector<vector<ll>> cumvs(4, vector<ll>(1, 0)); int i = 0; for (auto vec: vv){ for (auto v: vec) cumvs[i].push_back(cumvs[i].back() + v); ++i; } int record = 0; int cum_w0 = 0; for (auto cum_v0: cumvs[0]){ if (cum_w0 > W) break; int cum_w1 = cum_w0; cum_w0 += min_w; for (auto cum_v1: cumvs[1]){ if (cum_w1 > W) break; int cum_w2 = cum_w1; cum_w1 += min_w + 1; for (auto cum_v2: cumvs[2]){ if (cum_w2 > W) break; int cum_w3 = cum_w2; cum_w2 += min_w + 2; for (auto cum_v3: cumvs[3]){ if (cum_w3 > W) break; cum_w3 += min_w + 2; record = max(cum_v0 + cum_v1 + cum_v2 + cum_v3, record); } } } } return record; }
a.cc: In function 'll solve(int, int, std::vector<long long int>&, std::vector<long long int>&)': a.cc:54:33: error: no matching function for call to 'max(long long int, int&)' 54 | record = max(cum_v0 + cum_v1 + cum_v2 + cum_v3, record); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)' 257 | max(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed: a.cc:54:33: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 54 | record = max(cum_v0 + cum_v1 + cum_v2 + cum_v3, record); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)' 303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)' 5706 | max(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)' 5716 | max(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed: a.cc:54:33: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 54 | record = max(cum_v0 + cum_v1 + cum_v2 + cum_v3, record); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s113407831
p03732
C++
#include <cstdio> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <algorithm> using namespace std; const int MaxN = 1e5; typedef long long LL; ? int sum; int n, V; int w[105], v[105]; int a[105]; int dp[105][105][405]; //表示前i个物品中选j个容量为k int main() { while(scanf("%d %d", &n, &V) != EOF) { sum = 0; memset(dp, 0, sizeof(dp)); for(int i = 1; i <= n; i++) { scanf("%d %d", &w[i], &v[i]); a[i] = w[i] - w[1]; sum = sum + a[i]; } for(int i = 1; i <= n; i++) { for(int j = 1; j <= i; j++) { for(int k = 0; k < a[i]; k++) dp[i][j][k] = dp[i - 1][j][k]; } for(int j = 1; j <= i; j++) { for(int k = a[i]; k <= sum; k++) dp[i][j][k] = max(dp[i - 1][j][k], dp[i - 1][j - 1][k - a[i]] + v[i]); } } int ans = 0; for(int i = 1; i <= n; i++) for(int j = 1; j <= i; j++) { if(w[1] * j > V) break; for(int k = 0; k <= min(sum, V - w[1] * j); k++) ans = max(ans, dp[i][j][k]); } printf("%d\n", ans); } }
a.cc:10:1: error: expected unqualified-id before '?' token 10 | ? | ^ a.cc: In function 'int main()': a.cc:21:17: error: 'sum' was not declared in this scope 21 | sum = 0; | ^~~
s934301862
p03732
C++
#include <cstdio> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <algorithm> using namespace std; const int MaxN = 1e5; typedef long long LL; ? int sum; int n, V; int w[105], v[105]; int a[105]; int dp[105][105][405]; //表示前i个物品中选j个容量为k int main() { while(scanf("%d %d", &n, &V) != EOF) { sum = 0; memset(dp, 0, sizeof(dp)); for(int i = 1; i <= n; i++) { scanf("%d %d", &w[i], &v[i]); a[i] = w[i] - w[1]; sum = sum + a[i]; } for(int i = 1; i <= n; i++) { for(int j = 1; j <= i; j++) { for(int k = 0; k < a[i]; k++) dp[i][j][k] = dp[i - 1][j][k]; } for(int j = 1; j <= i; j++) { for(int k = a[i]; k <= sum; k++) dp[i][j][k] = max(dp[i - 1][j][k], dp[i - 1][j - 1][k - a[i]] + v[i]); } } int ans = 0; for(int i = 1; i <= n; i++) for(int j = 1; j <= i; j++) { if(w[1] * j > V) break; for(int k = 0; k <= min(sum, V - w[1] * j); k++) ans = max(ans, dp[i][j][k]); } printf("%d\n", ans); } }
a.cc:10:1: error: expected unqualified-id before '?' token 10 | ? | ^ a.cc: In function 'int main()': a.cc:21:17: error: 'sum' was not declared in this scope 21 | sum = 0; | ^~~
s928107516
p03732
C++
#include <cstdio> #include <cstdio> #include <cstring> #include <cstdlib> #include <cmath> #include <algorithm> using namespace std; const int MaxN = 1e5; typedef long long LL; ? int sum; int n, V; int w[105], v[105]; int a[105]; int dp[105][105][405]; //表示前i个物品中选j个容量为k int main() { while(scanf("%d %d", &n, &V) != EOF) { sum = 0; memset(dp, 0, sizeof(dp)); for(int i = 1; i <= n; i++) { scanf("%d %d", &w[i], &v[i]); a[i] = w[i] - w[1]; sum = sum + a[i]; } for(int i = 1; i <= n; i++) { for(int j = 1; j <= i; j++) { for(int k = 0; k < a[i]; k++) dp[i][j][k] = dp[i - 1][j][k]; } for(int j = 1; j <= i; j++) { for(int k = a[i]; k <= sum; k++) dp[i][j][k] = max(dp[i - 1][j][k], dp[i - 1][j - 1][k - a[i]] + v[i]); } } int ans = 0; for(int i = 1; i <= n; i++) for(int j = 1; j <= i; j++) { if(w[1] * j > V) break; for(int k = 0; k <= min(sum, V - w[1] * j); k++) ans = max(ans, dp[i][j][k]); } printf("%d\n", ans); } }
a.cc:10:1: error: expected unqualified-id before '?' token 10 | ? | ^ a.cc: In function 'int main()': a.cc:21:17: error: 'sum' was not declared in this scope 21 | sum = 0; | ^~~
s898405201
p03732
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for (ll (i)=(0);(i)<(ll)(n);++(i)) typedef pair<int, int> P; typedef long long ll; vector<int> v[4]; vector<int> w; int N, W; int main() { cin >> N >> W; rep(i, N) { int wi, vi; cin >> wi >> vi; if (w.size() == 0) { w.push_back(wi); v[w.size()-1].push_back(vi); } else { bool f=true; rep(j, w.size()) { if (w[j] == wi) { v[j].push_back(vi); f=false; } } if (f) { w.push_back(wi); v[w.size()-1].push_back(vi); } } } rep(i, w.size()) { sort(v[i].begin(), v[i].end(), greater<int>()); } for (int i=w.size(); i<4; ++i) w.push_back(0); for (int i=0; i<4; ++i) { res = max(res, v[i].size()); } for (int i=0; i<4; ++i) { if (v[i].size() < res) for (int j=v[i].size(); j<res; ++j) v[i].push_back(0); } res = 0; int sum1=0; for (int i=0; i<v[0].size(); ++i) { sum1 += v[0][i]; int sum2 = 0; for (int j=0; j<v[1].size(); ++j) { sum2 += v[1][j]; int sum3 = 0; for (int k=0; k<v[2].size(); ++k) { sum3 += v[2][k]; int sum4 = 0; for (int l=0; l<v[3].size(); ++l) { sum4 += v[3][l]; int t = 0; if (W >= w[0]*(i+1)+w[1]*(j+1)+w[2]*(k+1)+w[3]*(l+1)) { res = max(res, sum1+sum2+sum3+sum4); } } } } } cout << res << endl; }
a.cc: In function 'int main()': a.cc:40:9: error: 'res' was not declared in this scope; did you mean 'rep'? 40 | res = max(res, v[i].size()); | ^~~ | rep a.cc:43:27: error: 'res' was not declared in this scope; did you mean 'rep'? 43 | if (v[i].size() < res) for (int j=v[i].size(); j<res; ++j) v[i].push_back(0); | ^~~ | rep a.cc:46:5: error: 'res' was not declared in this scope; did you mean 'rep'? 46 | res = 0; | ^~~ | rep
s674686869
p03732
C++
#define _CRT_SECURE_NO_WARNINGS #include <array> #include <iostream> namespace Program { using namespace std; class Solver { private: // 荷物の個数 整数 int N; // ナップサックの許容重量 整数 int W; // 価値 v[i] array<long long int, 100> v; // 重さ w[i] array<long long int, 100> w; public: Solver() { cin.tie(0); ios::sync_with_stdio(false); cin >> N >> W; // 重量オーバー除外後 荷物の個数 整数 int overN = 0; int tmpw, tmpv; cin >> tmpw >> tmpv; for (int i = 1; i <= N; i++) { if (W < tmpw) overN++; else { w[i - overN - 1] = tmpw; v[i - overN - 1] = tmpv; } if (i == N) break; cin >> tmpw >> tmpv; } N = N - overN; } void Solve() { // それぞれ荷物の重量が1000以内のときに使用するナップサック cout << knapsackW(w, v, N, W) << endl; } // それぞれ荷物の重量が1000以内のときに使用するナップサック long long int knapsackW( const array<long long int, 100> &w, /* 重さ */ const array<long long int, 100> &v, /* 価値 */ const long long int &numOfItems, /* 荷物の個数 */ const long long int &wUpperBound /* 総重量の上限 */ ) { // 動的計画法 array<array<long long int, 300>, 100> dp; long long int j; for (long i = 0; i < N; i++) dp[i].fill(0); /* 価値の総和の最大値 動的計画法 */ for (long i = 0; i < numOfItems; i++) { for (j = 0; j <= wUpperBound; j++) { if (w[i] <= j && dp[i][j] < dp[i][j - w[i]] + v[i]) { dp[i + 1][j] = dp[i][j - w[i]] + v[i]; } else { dp[i + 1][j] = dp[i][j]; } } } // 最大価値 return N == 0 ? 0 : dp[numOfItems][wUpperBound]; } }; } int main() { // メモリリーク検出 _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_DELAY_FREE_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_LEAK_CHECK_DF); // メンバ関数ポインタ取得 void (Program::Solver::*pSolve)() = &Program::Solver::Solve; // コンストラクタ呼び出し Program::Solver obj; // .*演算子でアクセス (obj.*pSolve)(); return 0; }
a.cc: In function 'int main()': a.cc:98:20: error: '_CRTDBG_ALLOC_MEM_DF' was not declared in this scope 98 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | ^~~~~~~~~~~~~~~~~~~~ a.cc:99:11: error: '_CRTDBG_DELAY_FREE_MEM_DF' was not declared in this scope 99 | | _CRTDBG_DELAY_FREE_MEM_DF | ^~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:100:11: error: '_CRTDBG_CHECK_ALWAYS_DF' was not declared in this scope 100 | | _CRTDBG_CHECK_ALWAYS_DF | ^~~~~~~~~~~~~~~~~~~~~~~ a.cc:101:11: error: '_CRTDBG_LEAK_CHECK_DF' was not declared in this scope 101 | | _CRTDBG_LEAK_CHECK_DF); | ^~~~~~~~~~~~~~~~~~~~~ a.cc:98:5: error: '_CrtSetDbgFlag' was not declared in this scope 98 | _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | ^~~~~~~~~~~~~~
s308557403
p03732
Java
import java.util.HashMap; import java.util.Scanner; public class Main { public static HashMap<Point,Integer> map = new HashMap<Point,Integer>(); static int N,W; static int[] w,v; // static int count =0; public static void main(String[] args){ Scanner io = new Scanner(System.in); N = io.nextInt(); W = io.nextInt(); w = new int[N+1]; v = new int[N+1]; for (int i = 0; i < N; i++) { w[i+1] = io.nextInt(); v[i+1] = io.nextInt(); } // long time1 = System.currentTimeMillis(); System.out.println(value(N,W)); // long time2; // time2 = System.currentTimeMillis(); // System.out.println("\ntime02:"+(time2 -time1)); // System.out.println("count:: "+count); } public static int value(int i,int wMax){ Point p = new Point(i,wMax); // System.out.print("now i wMax: "+i+" "+wMax+" /"); if(map.containsKey(p)){ // System.out.println("ok!"); return map.get(p); } // System.out.println("non"); count ++; int val; if(i==0){ val = 0; }else if(wMax<w[i]){ val = value(i-1,wMax); }else{ val = Math.max(value(i-1,wMax),value(i-1,wMax-w[i])+v[i]); } map.put(p,val); return val; } } class Point{ int i; int w; public Point(int i, int w){ this.i = i; this.w = w; } @Override public boolean equals(Object p){ return (i==((Point)p).i && w==((Point)p).w); } @Override public int hashCode(){ return w % 10000; } }
Main.java:39: error: cannot find symbol count ++; ^ symbol: variable count location: class Main 1 error
s185701683
p03732
C
#include<stdio.h> int main(void){ int lop,lop2,lop3,n,w,ndata[100][2],ans[100],taihi,sakai[4],npr=0,kte=0,hanbun; scanf("%d",&n); scanf("%d",&w); for(lop=0;lop<4;lop++){ sakai[lop]=0; } for(lop=0;lop<n;lop++){ scanf("%d",&ndata[lop][0]); scanf("%d",&ndata[lop][1]); } for(lop=0;lop<n;lop++){ for(lop2=1;lop2<n;lop2++){ if(ndata[lop2-1][0]<ndata[lop2][0]){ taihi=ndata[lop2-1][0]; ndata[lop2-1][0]=ndata[lop2][0]; ndata[lop2][0]=taihi; taihi=ndata[lop2-1][1]; ndata[lop2-1][1]=ndata[lop2][1]; ndata[lop2][1]=taihi; }else if(ndata[lop-1][0]==ndata[lop][0] && ndata[lop-1][1]<ndata[lop][1]){ taihi=ndata[lop2-1][0]; ndata[lop2-1][0]=ndata[lop2][0]; ndata[lop2][0]=taihi; taihi=ndata[lop2-1][1]; ndata[lop2-1][1]=ndata[lop2][1]; ndata[lop2][1]=taihi; } } lop2=1; sakai[0]=0; for(lop=1;lop<=n;lop++){ if(ndata[lop-1][0]!=ndata[lop][0]){ sakai[lop2]=lop; lop2++; } } /*for(lop=0;lop<n;lop++){ printf("%d ",ndata[lop][0]); printf("%d \n",ndata[lop][1]); } for(lop3=0;lop3<4;lop3++){ for(lop=0;lop<sakai[lop3];lop++){ for(lop2=sakai[lop3]+1;lop2<sakai[lop3+1];lop2++){ if(ndata[lop2-1][1]<ndata[lop2][1]){ taihi=ndata[lop2-1][0]; ndata[lop2-1][0]=ndata[lop2][0]; ndata[lop2][0]=taihi; taihi=ndata[lop2-1][1]; ndata[lop2-1][1]=ndata[lop2][1]; ndata[lop2][1]=taihi; } } } }*/ for(lop=0;lop<n;lop++){ npr=w; ans[lop]=0; for(lop2=lop;lop2<n;lop2++){ if(npr-ndata[lop2][0]>=0){ ans[lop]+=ndata[lop2][1]; npr-=ndata[lop2][0]; } } } for(lop=1;lop<n;lop++){ if(ans[kte]<ans[lop]){ kte=lop; } } printf("%d\n",ans[kte]); return 0; }
main.c: In function 'main': main.c:95:1: error: expected declaration or statement at end of input 95 | } | ^
s338074654
p03732
C
#include<stdio.h> int main(void){ int lop,lop2,lop3,n,w,ndata[100][2],ans[100],taihi,sakai[3],npr=0,kte=0,hanbun; scanf("%d",&n); scanf("%d",&w); for(lop=0;lop<3;lop++){ sakai[lop]=0; } for(lop=0;lop<n;lop++){ scanf("%d",&ndata[lop][0]); scanf("%d",&ndata[lop][1]); } for(lop=0;lop<n;lop++){ for(lop2=1;lop2<n;lop2++){ if(ndata[lop2-1][0]<ndata[lop2][0]){ taihi=ndata[lop2-1][0]; ndata[lop2-1][0]=ndata[lop2][0]; ndata[lop2][0]=taihi; taihi=ndata[lop2-1][1]; ndata[lop2-1][1]=ndata[lop2][1]; ndata[lop2][1]=taihi; } } } lop2=0; for(lop=1;lop<n;lop++){ if(ndata[lop-1][0]!=ndata[lop][0]){ sakai[lop2]=lop-1; lop2++; } } for(lop3=0;lop3<3;lop3++){ for(lop=0;lop<sakai[lop3];lop++){ for(lop2=1;lop2<sakai[lop3];lop2++){ if(ndata[lop2-1][1]<ndata[lop2][1]){ taihi=ndata[lop2-1][0]; ndata[lop2-1][0]=ndata[lop2][0]; ndata[lop2][0]=taihi; taihi=ndata[lop2-1][1]; ndata[lop2-1][1]=ndata[lop2][1]; ndata[lop2][1]=taihi; } } } } for(lop=0;lop<n;lop++){ npr=w; ans[lop]=0; for(lop2=lop;lop2<n;lop2++){ if(npr-ndata[lop2][0]>=0){ ans[lop]+=ndata[lop2][1]; npr-=ndata[lop2][0]; } } } lop=hanubn; for(lop=0;lop<n;lop++){ for(lop2=1;lop2<n;lop2++){ if(ndata[lop2-1][0]<ndata[lop2][0]){ taihi=ndata[lop2-1][0]; ndata[lop2-1][0]=ndata[lop2][0]; ndata[lop2][0]=taihi; taihi=ndata[lop2-1][1]; ndata[lop2-1][1]=ndata[lop2][1]; ndata[lop2][1]=taihi; } } } lop2=0; for(lop=1;lop<n;lop++){ if(ndata[lop-1][0]!=ndata[lop][0]){ sakai[lop2]=lop-1; lop2++; } } for(lop3=0;lop3<3;lop3++){ for(lop=0;lop<sakai[lop3];lop++){ for(lop2=1;lop2<sakai[lop3];lop2++){ if(ndata[lop2-1][1]<ndata[lop2][1]){ taihi=ndata[lop2-1][0]; ndata[lop2-1][0]=ndata[lop2][0]; ndata[lop2][0]=taihi; taihi=ndata[lop2-1][1]; ndata[lop2-1][1]=ndata[lop2][1]; ndata[lop2][1]=taihi; } } } } for(lop=0;lop<n;lop++){ npr=w; ans[lop+hanubn]=0; for(lop2=lop;lop2<n;lop2++){ if(npr-ndata[lop2][0]>=0){ ans[lop+hanubn]+=ndata[lop2][1]; npr-=ndata[lop2][0]; } } } //printf("%d\n",ans[0]); for(lop=1;lop<n;lop++){ //printf("%d\n",ans[lop]); if(ans[kte]<ans[lop]){ kte=lop; } } //printf("\n\n\n"); printf("%d\n",ans[kte]); return 0; }
main.c: In function 'main': main.c:70:13: error: 'hanubn' undeclared (first use in this function); did you mean 'hanbun'? 70 | lop=hanubn; | ^~~~~~ | hanbun main.c:70:13: note: each undeclared identifier is reported only once for each function it appears in
s831943332
p03732
C
for(lop=0;lop<n;lop++){ npr=w; ans[lop]=0; for(lop2=lop;lop2<n;lop2++){ if(npr-ndata[lop2][0]>=0){ ans[lop]+=ndata[lop2][1]; npr-=ndata[lop2][0]; } } }
main.c:1:1: error: expected identifier or '(' before 'for' 1 | for(lop=0;lop<n;lop++){ | ^~~ main.c:1:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 1 | for(lop=0;lop<n;lop++){ | ^ main.c:1:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token 1 | for(lop=0;lop<n;lop++){ | ^~
s898441382
p03732
C
for(lop=0;lop<n;lop++){ npr=w; ans[lop]=0; for(lop2=lop;lop2<n;lop2++){ if(npr-ndata[lop2][0]>=0){ ans[lop]+=ndata[lop2][1]; npr-=ndata[lop2][0]; } } }
main.c:1:1: error: expected identifier or '(' before 'for' 1 | for(lop=0;lop<n;lop++){ | ^~~ main.c:1:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 1 | for(lop=0;lop<n;lop++){ | ^ main.c:1:20: error: expected '=', ',', ';', 'asm' or '__attribute__' before '++' token 1 | for(lop=0;lop<n;lop++){ | ^~
s297284151
p03732
C++
#include <iostream> int N, W; int w[100]; int v[100]; int dp[101][101]; int rec(int i, int j) { if (dp[i][j] >= 0) { return dp[i][j]; } int val; if (i == N) { val = 0; } else if (j < w[i]) { val = rec(i+1, j); } else { val = std::max(rec(i+1, j), rec(i+1, j-w[i])+v[i]); } dp[i][j] = val; return val; } int main() { std::cin >> N >> W; std::memset(dp, -1, sizeof(dp)); for (int i = 0; i < N; i++) { std::cin >> w[i] >> v[i]; } std::cout << rec(0, W) << std::endl; return 0; }
a.cc: In function 'int main()': a.cc:26:8: error: 'memset' is not a member of 'std'; did you mean 'wmemset'? 26 | std::memset(dp, -1, sizeof(dp)); | ^~~~~~ | wmemset
s449276950
p03732
C++
#include <iostream> int N, W; int w[100]; int v[100]; int dp[101][101]; int rec(int i, int j) { if (dp[i][j] >= 0) { return dp[i][j]; } int val; if (i == N) { val = 0; } else if (j < w[i]) { val = rec(i+1, j); } else { val = std::max(rec(i+1, j), rec(i+1, j-w[i])+v[i]); } dp[i][j] = val; return val; } int main() { std::cin >> N >> W; memset(dp, -1, sizeof(dp)); for (int i = 0; i < N; i++) { std::cin >> w[i] >> v[i]; } std::cout << rec(0, W) << std::endl; return 0; }
a.cc: In function 'int main()': a.cc:26:3: error: 'memset' was not declared in this scope 26 | memset(dp, -1, sizeof(dp)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 |
s644967358
p03732
C++
#include <iostream> using namespace std; int main(){ int N; long long W; cin >> N >> W; long long w[N+1],v[N+1]; for(int i=1;i<=N;i++){ cin >> w[i] >> v[i]; } long long dp[N+1][W+1]; memset(dp, -1, sizeof(dp)); for(int i=0;i<=W;i++) dp[0][i] =0; for(int i=1;i<=N;i++){ for(int j=0;j<=W;j++){ // the index? if(j >= w[i]){ dp[i][j] = max(dp[i-1][j-w[i]]+v[i], dp[i-1][j]); }else{ dp[i][j] = dp[i-1][j]; } } } //for(int i=0;i<=N;i++){ // for(int j=0;j<=W;j++){ // cout << dp[i][j] << " "; // } // cout << endl; // } cout << dp[N][W] << endl; return 0; }
a.cc: In function 'int main()': a.cc:14:5: error: 'memset' was not declared in this scope 14 | memset(dp, -1, sizeof(dp)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | using namespace std;
s417415996
p03732
C++
#include <cstdio> #include <cstdlib> #include <vector> #include <algorithm> #include <map> #include <bitset> #include <unordered_set> #include <set> const INT_MIN = -0x7fffffff - 1; using namespace std; int n, wei; int main() { scanf("%d %d", &n, &wei); vector<int> w(n); vector<int> v(n); for (int i = 0; i < n; i++) { scanf("%d %d", &w[i], &v[i]); } vector<vector<int>> dp(n + 1, vector<int>(3 * n + 1, INT_MIN)); dp[0][0] = 0; for(int i = 0; i < n; i++) { for(int a = n; a >= 0; a--) { for(int b = 0; b <= 3 * n; b++) { if(dp[a][b] >= 0) { int b2 = b+ w[i] - w[0]; dp[a + 1][b2] = max(dp[a][b] + v[i], dp[a + 1][b2]); } } } } int ans = INT_MIN; for(int i = 0; i <= n; i++) { for(int j = 0; j <= 3 *n; j++) { if(i * w[0] + j <= wei) { ans = max(ans, dp[i][j]); } } } printf("%d\n", ans); return 0; }
a.cc:9:7: error: 'INT_MIN' does not name a type 9 | const INT_MIN = -0x7fffffff - 1; | ^~~~~~~ a.cc:9:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 8 | #include <set> +++ |+#include <climits> 9 | const INT_MIN = -0x7fffffff - 1; a.cc: In function 'int main()': a.cc:19:58: error: 'INT_MIN' was not declared in this scope 19 | vector<vector<int>> dp(n + 1, vector<int>(3 * n + 1, INT_MIN)); | ^~~~~~~ a.cc:19:58: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s637271780
p03732
C++
#include <cstdio> #include <cstdlib> #include <vector> #include <algorithm> #include <map> #include <bitset> #include <unordered_set> #include <set> using namespace std; int n, wei; int main() { scanf("%d %d", &n, &wei); vector<int> w(n); vector<int> v(n); for (int i = 0; i < n; i++) { scanf("%d %d", &w[i], &v[i]); } vector<vector<int>> dp(n + 1, vector<int>(3 * n + 1, INT_MIN)); dp[0][0] = 0; for(int i = 0; i < n; i++) { for(int a = n; a >= 0; a--) { for(int b = 0; b <= 3 * n; b++) { if(dp[a][b] >= 0) { int b2 = b+ w[i] - w[0]; dp[a + 1][b2] = max(dp[a][b] + v[i], dp[a + 1][b2]); } } } } int ans = INT_MIN; for(int i = 0; i <= n; i++) { for(int j = 0; j <= 3 *n; j++) { if(i * w[0] + j <= wei) { ans = max(ans, dp[i][j]); } } } printf("%d\n", ans); return 0; }
a.cc: In function 'int main()': a.cc:18:58: error: 'INT_MIN' was not declared in this scope 18 | vector<vector<int>> dp(n + 1, vector<int>(3 * n + 1, INT_MIN)); | ^~~~~~~ a.cc:9:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 8 | #include <set> +++ |+#include <climits> 9 | using namespace std;
s434128777
p03732
C++
#include <iostream> #include <vector> #include <algorithm> #include <math.h> using namespace std; int N, W, w1; int values[4][101]; void Solve(int num[4]){ int best = 0; int n[4]; for(n[0]=0; n[0]<=num[0]; n[0]++){ for(n[1]=0; n[1]<=num[1]; n[1]++){ for(n[2]=0; n[2]<=num[2]; n[2]++){ for(n[3]=0; n[3]<=num[3]; n[3]++){ int weight = 0; for( i=0; i<=3; i++){ weight += n[i]*(w1+i); } if(weight > W){ break; } int v_sum = 0; for(int i=0; i<=3; i++){ for(int j=0; j<n[i]; j++){ v_sum += values[i][j]; } } if(v_sum > best){ best = v_sum; } } } } } cout << best << endl; } int main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> N >> W; int v; cin >> w1 >> v; int num[4]; values[0][0] = v; num[0] = 1; for(int i=1; i<N; i++){ int w; cin >> w >> v; values[w-w1][num[w-w1]++] = v; } for(int i=0; i<4; i++){ sort(values[i], values[i] + num[i], greater<int>()); } // for(int i=0; i<4; i++){ // for(int j=0; j<num[i]; j++) // cout << values[i][j] << " "; // cout << endl; // } Solve(num); return 0; }
a.cc: In function 'void Solve(int*)': a.cc:19:24: error: 'i' was not declared in this scope 19 | for( i=0; i<=3; i++){ | ^
s527792375
p03732
C++
#include "iostream" #include "cstdio" #include "cstring" #include "string" #include "map" using namespace std; const int maxn=; map<long long,long long>dp; int n,c; int main() { scanf("%d%d",&n,&c); for(int i=1;i<=n;i++){ int v,w; scanf("%d%d",&w,&v); for(int j=c;j>=0;j--){ if(j>=v) dp[j]=max(dp[j],dp[j-v]+w); } cout<<dp[c]<<endl; } }
a.cc:7:16: error: expected primary-expression before ';' token 7 | const int maxn=; | ^
s056285183
p03732
C++
#include <utility> #include <vector> using namespace std; //重さの和j以下で最初からi個まで選べるときの最大の価値 long weights[100],values[100]; map<pair<int,int>,long> table; int max_value(const pair<int,int> &p){ int i = p.first,j = p.second; auto p1 = make_pair(i-1,j); if(table.count(p1)==0) table[p1] = max_value(p1); if(j-weights[i-1]<0) return table[p1]; auto p2 = make_pair(i-1,j-weights[i-1]); if(table.count(p2)==0) table[p2] = max_value(p2); return max(table[p1],table[p2]+values[i-1]); } int main(){ int N,W; cin>>N>>W; for(int i=0;i<N;++i){ cin>>weights[i]>>values[i]; } for(int i=0;i<=N;++i) table[make_pair(i,0)]=0; for(int j=0;j<=W;++j) table[make_pair(0,j)]=0; cout<<max_value(make_pair(N,W))<<endl; return 0; }
a.cc:8:1: error: 'map' does not name a type 8 | map<pair<int,int>,long> table; | ^~~ a.cc: In function 'int max_value(const std::pair<int, int>&)': a.cc:13:6: error: 'table' was not declared in this scope; did you mean 'mutable'? 13 | if(table.count(p1)==0) table[p1] = max_value(p1); | ^~~~~ | mutable a.cc:14:31: error: 'table' was not declared in this scope; did you mean 'mutable'? 14 | if(j-weights[i-1]<0) return table[p1]; | ^~~~~ | mutable a.cc:17:6: error: 'table' was not declared in this scope; did you mean 'mutable'? 17 | if(table.count(p2)==0) table[p2] = max_value(p2); | ^~~~~ | mutable a.cc:19:14: error: 'table' was not declared in this scope; did you mean 'mutable'? 19 | return max(table[p1],table[p2]+values[i-1]); | ^~~~~ | mutable a.cc: In function 'int main()': a.cc:24:3: error: 'cin' was not declared in this scope 24 | cin>>N>>W; | ^~~ a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 2 | #include <vector> +++ |+#include <iostream> 3 | a.cc:29:25: error: 'table' was not declared in this scope; did you mean 'mutable'? 29 | for(int i=0;i<=N;++i) table[make_pair(i,0)]=0; | ^~~~~ | mutable a.cc:30:25: error: 'table' was not declared in this scope; did you mean 'mutable'? 30 | for(int j=0;j<=W;++j) table[make_pair(0,j)]=0; | ^~~~~ | mutable a.cc:32:3: error: 'cout' was not declared in this scope 32 | cout<<max_value(make_pair(N,W))<<endl; | ^~~~ a.cc:32:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:32:36: error: 'endl' was not declared in this scope 32 | cout<<max_value(make_pair(N,W))<<endl; | ^~~~ a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 2 | #include <vector> +++ |+#include <ostream> 3 |
s642048066
p03732
C++
#include <iostream> #include <vector> #include <numeric> using namespace std; int main () { long N, W; cin >> N >> W; long w[101], v[101]; for (int i = 0; i < N ; i++) { cin >> w[i] >> v[i]; } vector<long> v0, v1, v2, v3; for (int i = 0; i < N; i++) { if (w[i] == w[0]) { v0.push_back(v[i]); } else if (w[i] == w[0] + 1) { v1.push_back(v[i]); } else if (w[i] == w[0] + 2) { v2.push_back(v[i]); } else { v3.push_back(v[i]); } } sort(v0.begin(), v0.end(), greater<long>()); sort(v1.begin(), v1.end(), greater<long>()); sort(v2.begin(), v2.end(), greater<long>()); sort(v3.begin(), v3.end(), greater<long>()); int l0 = v0.size(); int l1 = v1.size(); int l2 = v2.size(); int l3 = v3.size(); long sum = 0; for (int a = 0; a <= l0; a++) { for (int b = 0; b <= l1; b++) { for (int c = 0; c <= l2; c++) { for (int d = 0; d <= l3; d++) { long s = accumulate(v0.begin(), v0.begin() + a, 0) + accumulate(v1.begin(), v1.begin() + b, 0) + accumulate(v2.begin(), v2.begin() + c, 0) + accumulate(v3.begin(), v3.begin() + d, 0); if (w[0] * a + (w[0] + 1) * b + (w[0] + 2) * c + (w[0] + 3) * d <= W and sum < s) { sum = s; } } } } } cout << sum << endl; }
a.cc: In function 'int main()': a.cc:29:5: error: 'sort' was not declared in this scope; did you mean 'short'? 29 | sort(v0.begin(), v0.end(), greater<long>()); | ^~~~ | short
s855098109
p03732
C++
#include <iostream> #include <cstdio> #include <cmath> #include <cstdio> #include <cstring> #include <string> #include <vector> #include <set> #include <map> #include <stack> #include <queue> #include <algorithm> #define CH(N,A,B) (A<=N&&N<B) #define REP(i,a,b) for(int i=a;i<b;i++) #define RREP(i,a,b) for(int i=(b-1);a<=i;i--) using namespace std; int INF = 1000000005; int main() { int N, W, w[105], v[105]; int minw = INF; cin>>N>>W; REP(i,0,N){ cin>>w[i]>>v[i]; minw = min(minw, w[i]); } long long dp[105][310]; REP(i,0,105)REP(j,0,310) dp[i][j] = 0; REP(i,1,N+1){ REP(j,0,(W-minw)+2){ //if(j < w[i-1]-minw+1) continue; long long tmp = (j+minw-1)-w[i-1] int ind; if(0 <= tmp && tmp < minw) ind = 0; else if(minw <= tmp) ind = (j+minw-1) - w[i-1]-1; if(0 <= ind && j >= w[i-1]-minw+1) dp[i][j] = max(dp[i-1][j], dp[i-1][ind] + v[i-1]); else dp[i][j] = dp[i-1][j]; } } cout<<dp[N][W-minw+1]<<endl; //test /* REP(i,0,N+1){ REP(j,0,(W-minw)+5){ cout<<dp[i][j]<<" "; } cout<<endl; } */ return 0; }
a.cc: In function 'int main()': a.cc:39:7: error: expected ',' or ';' before 'int' 39 | int ind; | ^~~ a.cc:41:34: error: 'ind' was not declared in this scope; did you mean 'int'? 41 | if(0 <= tmp && tmp < minw) ind = 0; | ^~~ | int a.cc:42:28: error: 'ind' was not declared in this scope; did you mean 'int'? 42 | else if(minw <= tmp) ind = (j+minw-1) - w[i-1]-1; | ^~~ | int a.cc:44:15: error: 'ind' was not declared in this scope; did you mean 'int'? 44 | if(0 <= ind && j >= w[i-1]-minw+1) dp[i][j] = max(dp[i-1][j], dp[i-1][ind] + v[i-1]); | ^~~ | int
s369098306
p03732
C++
#include <iostream> #include <vector> #include <map> using namespace std; #define pii map<int,int> int n,w; //添え字p,残り容量qから最大の利益となる利益vを返す int np(vector<pii> &item, int p, int q){ static vector<vector<int>> dp; for(auto a : dp){ if(a[0]==p && a[1]==q){ return a[2]; } } int v; if(p==n){ v=0; }else if(q<item[p].first){ v=np(item,p+1,q); }else{ v=max(np(item,p+1,q), np(item,p+1,q-item[p].first)+item[p].second); } dp.push_back(vector<int>{p,q,v}); return v; } int main(void){ cin>>n>>w; vector<pii> item(n,pii(0,0)); for(int i=0;i<n;i++){ cin>>item[i].first>>item[i].second; } cout<<np(item,0,w); }
a.cc: In function 'int np(std::vector<std::map<int, int> >&, int, int)': a.cc:21:24: error: '__gnu_cxx::__alloc_traits<std::allocator<std::map<int, int> >, std::map<int, int> >::value_type' {aka 'class std::map<int, int>'} has no member named 'first' 21 | }else if(q<item[p].first){ | ^~~~~ a.cc:24:53: error: '__gnu_cxx::__alloc_traits<std::allocator<std::map<int, int> >, std::map<int, int> >::value_type' {aka 'class std::map<int, int>'} has no member named 'first' 24 | v=max(np(item,p+1,q), np(item,p+1,q-item[p].first)+item[p].second); | ^~~~~ a.cc:24:68: error: '__gnu_cxx::__alloc_traits<std::allocator<std::map<int, int> >, std::map<int, int> >::value_type' {aka 'class std::map<int, int>'} has no member named 'second' 24 | v=max(np(item,p+1,q), np(item,p+1,q-item[p].first)+item[p].second); | ^~~~~~ a.cc: In function 'int main()': a.cc:34:22: error: '__gnu_cxx::__alloc_traits<std::allocator<std::map<int, int> >, std::map<int, int> >::value_type' {aka 'class std::map<int, int>'} has no member named 'first' 34 | cin>>item[i].first>>item[i].second; | ^~~~~ a.cc:34:37: error: '__gnu_cxx::__alloc_traits<std::allocator<std::map<int, int> >, std::map<int, int> >::value_type' {aka 'class std::map<int, int>'} has no member named 'second' 34 | cin>>item[i].first>>item[i].second; | ^~~~~~ In file included from /usr/include/c++/14/map:63, from a.cc:3: /usr/include/c++/14/bits/stl_map.h: In instantiation of 'std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]': a.cc:32:31: required from here 32 | vector<pii> item(n,pii(0,0)); | ^ /usr/include/c++/14/bits/stl_map.h:287:38: error: no matching function for call to 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::_M_insert_range_unique(int&, int&)' 287 | { _M_t._M_insert_range_unique(__first, __last); } | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/map:62: /usr/include/c++/14/bits/stl_tree.h:1096:9: note: candidate: 'template<class _InputIterator> std::__enable_if_t<((bool)std::is_same<_Val, typename std::iterator_traits<_InputIterator>::value_type>::value)> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_range_unique(_InputIterator, _InputIterator) [with _Key = int; _Val = std::pair<const int, int>; _KeyOfValue = std::_Select1st<std::pair<const int, int> >; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]' 1096 | _M_insert_range_unique(_InputIterator __first, _InputIterator __last) | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1096:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_tree.h: In substitution of 'template<class _InputIterator> std::__enable_if_t<((bool)std::is_same<std::pair<const int, int>, typename std::iterator_traits< <template-parameter-1-1> >::value_type>::value), void> std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::_M_insert_range_unique(_InputIterator, _InputIterator) [with _InputIterator = int]': /usr/include/c++/14/bits/stl_map.h:287:31: required from 'std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]' 287 | { _M_t._M_insert_range_unique(__first, __last); } | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ a.cc:32:31: required from here 32 | vector<pii> item(n,pii(0,0)); | ^ /usr/include/c++/14/bits/stl_tree.h:1095:58: error: no type named 'value_type' in 'struct std::iterator_traits<int>' 1095 | __enable_if_t<__same_value_type<_InputIterator>::value> | ^~~~~ /usr/include/c++/14/bits/stl_map.h: In instantiation of 'std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]': a.cc:32:31: required from here 32 | vector<pii> item(n,pii(0,0)); | ^ /usr/include/c++/14/bits/stl_tree.h:1105:9: note: candidate: 'template<class _InputIterator> std::__enable_if_t<((bool)(! std::is_same<_Val, typename std::iterator_traits<_InputIterator>::value_type>::value))> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_range_unique(_InputIterator, _InputIterator) [with _Key = int; _Val = std::pair<const int, int>; _KeyOfValue = std::_Select1st<std::pair<const int, int> >; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]' 1105 | _M_insert_range_unique(_InputIterator __first, _InputIterator __last) | ^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_tree.h:1105:9: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_tree.h: In substitution of 'template<class _InputIterator> std::__enable_if_t<((bool)(! std::is_same<std::pair<const int, int>, typename std::iterator_traits< <template-parameter-1-1> >::value_type>::value)), void> std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::_M_insert_range_unique(_InputIterator, _InputIterator) [with _InputIterator = int]': /usr/include/c++/14/bits/stl_map.h:287:31: required from 'std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = int; _Tp = int; _Compare = std::less<int>; _Alloc = std::allocator<std::pair<const int, int> >]' 287 | { _M_t._M_insert_range_unique(__first, __last); } | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ a.cc:32:31: required from here 32 | vector<pii> item(n,pii(0,0)); | ^ /usr/include/c++/14/bits/stl_tree.h:1104:59: error: no type named 'value_type' in 'struct std::iterator_traits<int>' 1104 | __enable_if_t<!__same_value_type<_InputIterator>::value> | ^~~~~
s411152646
p03732
C++
#include <iostream> #include <list> #include <vector> #include <string> #include <cmath> #include <algorithm> using namespace std; int n, w; int maxv = 0; size_t asize; vector<cl> arr; vector<int> vl; class cl { public: cl(int a, int b) : v(a), w(b) { vs = double(v) / w; } int v, w; double vs; }; bool operator<(const cl& left, const cl& right) { return left.vs < right.vs; } void f(size_t num, int vadd, int wadd, int passed) { if (maxv > vadd + vl.back() - vl[passed]) { return; } if (passed + 1 == asize) { maxv = max(maxv, vadd); return; } if (wadd + arr[num].w <= w) { f(num + 1, vadd + arr[num].v, wadd + arr[num].w, passed + 1); } f(num + 1, vadd, wadd, passed + 1); } int main() { cin >> n; cin >> w; arr.reserve(n); vl.reserve(n); for (int i = 0; i < n; ++i) { int a, b; cin >> a; cin >> b; arr.emplace_back(b, a); } sort(arr.begin(), arr.end()); vl.emplace_back(); vl.emplace_back(arr[0].v); asize = arr.size(); for (size_t i = 1; i < asize; ++i) { vl.emplace_back(vl.back() + arr[i].v); } cout << maxv; }
a.cc:13:8: error: 'cl' was not declared in this scope 13 | vector<cl> arr; | ^~ a.cc:13:10: error: template argument 1 is invalid 13 | vector<cl> arr; | ^ a.cc:13:10: error: template argument 2 is invalid a.cc: In function 'void f(size_t, int, int, int)': a.cc:41:23: error: invalid types 'int[size_t {aka long unsigned int}]' for array subscript 41 | if (wadd + arr[num].w <= w) | ^ a.cc:43:38: error: invalid types 'int[size_t {aka long unsigned int}]' for array subscript 43 | f(num + 1, vadd + arr[num].v, wadd + arr[num].w, passed + 1); | ^ a.cc:43:57: error: invalid types 'int[size_t {aka long unsigned int}]' for array subscript 43 | f(num + 1, vadd + arr[num].v, wadd + arr[num].w, passed + 1); | ^ a.cc: In function 'int main()': a.cc:52:13: error: request for member 'reserve' in 'arr', which is of non-class type 'int' 52 | arr.reserve(n); | ^~~~~~~ a.cc:59:21: error: request for member 'emplace_back' in 'arr', which is of non-class type 'int' 59 | arr.emplace_back(b, a); | ^~~~~~~~~~~~ a.cc:62:18: error: request for member 'begin' in 'arr', which is of non-class type 'int' 62 | sort(arr.begin(), arr.end()); | ^~~~~ a.cc:62:31: error: request for member 'end' in 'arr', which is of non-class type 'int' 62 | sort(arr.begin(), arr.end()); | ^~~ a.cc:64:28: error: invalid types 'int[int]' for array subscript 64 | vl.emplace_back(arr[0].v); | ^ a.cc:65:21: error: request for member 'size' in 'arr', which is of non-class type 'int' 65 | asize = arr.size(); | ^~~~ a.cc:68:48: error: invalid types 'int[size_t {aka long unsigned int}]' for array subscript 68 | vl.emplace_back(vl.back() + arr[i].v); | ^
s481075739
p03732
C++
#include<iostream> #include <algorithm> #include<stdint> using namespace std; #define MAX 100 #define PATURN 4 int knapsack(int W, int w, int wm, int *ws, int wv[][MAX], int s[][MAX+1], int c, int v) { int ret = v; if (c >= PATURN) return 0; for (int i = 0;i <= ws[c];i ++) { if (w+(wm+c)*i<=W) ret = max(ret, knapsack(W, w+(wm+c)*i, wm, ws, wv, s, c+1, v+s[c][i])); } return ret; } int main() { int n, w, wm, ws[PATURN], wv[PATURN][MAX], wc, s[PATURN][MAX+1]; for (int i = 0;i < PATURN;i ++) { ws[i] = 0; } cin >> n >> w; cin >> wm >> wv[0][0]; ws[0] ++; for (int i = 1;i < n;i ++) { cin >> wc; cin >> wv[wc-wm][ws[wc-wm]]; ws[wc-wm] ++; } for (int i = 0;i < PATURN;i ++) { sort(wv[i], wv[i]+ws[i]); s[i][0] = 0; for (int j = 0;j < ws[i];j ++) { s[i][j+1] = s[i][j] + wv[i][j]; } } int ret = 0; for (int i = 0;i <= ws[0];i ++) { if (wm*i<=w) ret = max(ret, knapsack(w, wm*i, wm, ws, wv, s, 1, s[0][i])); } cout << ret; }
a.cc:3:9: fatal error: stdint: No such file or directory 3 | #include<stdint> | ^~~~~~~~ compilation terminated.
s037375475
p03732
C++
#include <iostream> #include <cstdio> using namespace std; typedef long long ll; ll dp[1000000100]; int v[100000010],w[100000010]; const ll INF=(ll)1<<62; int main() { int T; int n,b; scanf("%d%d",&n,&b); ll tot_w=0,tot_v=0; for(int i=0 ; i<n ; ++i) { scanf("%d%d",&w[i],&v[i]); tot_v+=v[i]; tot_w+=w[i]; } for(int i=0 ; i<=tot_v ; ++i) { dp[i]=INF; } dp[tot_v]=tot_w; for(int i=0 ; i<n ; ++i) { for(int j=0 ; j<=tot_v ; ++j) { if(j-v[i]>=0) { if(dp[j]-w[i]>=0) dp[j-v[i]]=min(dp[j-v[i]],dp[j]-w[i]); } } } for(int i=tot_v ; i>=0 ; --i) { if(dp[i]<=b) { printf("%d\n",i); break; } } return 0; }
/tmp/ccnB2VFA.o: in function `main': a.cc:(.text+0x53): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccnB2VFA.o a.cc:(.text+0x6a): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccnB2VFA.o a.cc:(.text+0x98): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccnB2VFA.o a.cc:(.text+0xb5): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccnB2VFA.o a.cc:(.text+0x14f): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccnB2VFA.o a.cc:(.text+0x18b): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccnB2VFA.o a.cc:(.text+0x1c8): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccnB2VFA.o a.cc:(.text+0x1e8): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccnB2VFA.o a.cc:(.text+0x229): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccnB2VFA.o collect2: error: ld returned 1 exit status
s936211867
p03732
C++
#include <iostream> #include <string> #define REP(i,k,n) for(int(i)=(k);(i)<(n);(i)++) using namespace std; const int MAX_N = 100; const long MAX_W = (long)1e9; int N; long w[MAX_N], v[MAX_N]; // メモ化テーブル long dp[MAX_N + 1][MAX_W + 1]; // i番目以降の品物から重さの総和が // j以下となるように選ぶ // 戻り値: その選び方をしたときの価値の総和 // j: 残りの容量 (重さ) long rec(int i, long j) { // メモを利用 if (dp[i][j] >= 0) return dp[i][j]; int res; if (i == N) res = 0; // 商品 i は入らない // 他の商品が入るか試す else if (j < w[i]) res = rec(i+1, j); // 商品 i を入れる場合・入れない場合を両方とも試して、 // たくさん入る方をとる else res = max(rec(i+1, j), rec(i+1, j - w[i]) + v[i]); dp[i][j] = res; return res; } int main() { long W; cin >> N >> W; REP(i,0,N) cin >> w[i] >> v[i]; // dp テーブル初期化 (-1 で) memset(dp, -1, sizeof(dp)); // REP(i,0,N+1) { // for (long j = 0; j < W + 1; ++j) dp[i][j] = -1; // } long res = rec(0, W); cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:42:3: error: 'memset' was not declared in this scope 42 | memset(dp, -1, sizeof(dp)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 | #include <string>
s722527597
p03732
C++
#include<bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; #define rep(i,n) for(int i=0;i<(int)(n);i++) #define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++) ll N; ll W; ll w[100]; ll v[100]; ll dp[100 + 1][100 + 1]; ll DP(ll i, ll j) { //i番目以降重さj以下 if (dp[i][j] != -1) { return dp[i][j]; } ll res; if (i == N) { res = 0; } else if (j < w[i]) { res = DP(i + 1, j); } else { res = max(DP(i + 1, j), DP(i + 1, j - w[i]) + v[i]); } return dp[i][j] = res; } int main() { cin.sync_with_stdio(false); cin >> N >> W; rep(i, N) { cin >> w[i] >> v[i]; if (W >= w[0]) { w[i] = w[i] - (w[0] - 1); if (i == 0) { W = W - (w[0] - 1); } else { w[i] = w[i]-W+1; W = 1; } } memset(dp, -1, sizeof(dp)); cout << DP(0, W) << endl; return 0; }
a.cc: In function 'int main()': a.cc:53:2: error: expected '}' at end of input 53 | } | ^ a.cc:32:12: note: to match this '{' 32 | int main() { | ^
s641580957
p03732
C++
#include <bits/stdc++.h> #include <stdio.h> using namespace std; #define FOR(i,a,b) for(int i=a;i<b;i++) #define REP(i,b) FOR(i,0,b) #define INF 1e9 int N,W,w[100],v[100],dp[100][10000]; int rec(int i,int j){ if (dp[i][j] >= 0) { return dp[i][j]; } int res; if (i == N) { res = 0; } else if (j < w[i]) { res = rec(i+1,j); } else { res = max(rec(i+1,j), rec(i+1,j-w[i])+v[i]); } return dp[i][j] = res; } void solve(){ menset(dp,-1,sizeof(dp)); printf("%d\n", rec(0, W)); } int main(){ cin>>N>>W; REP(i,N){ cin>>w[i]>>v[i]; } return 0; }
a.cc: In function 'void solve()': a.cc:28:3: error: 'menset' was not declared in this scope; did you mean 'memset'? 28 | menset(dp,-1,sizeof(dp)); | ^~~~~~ | memset
s927607388
p03732
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; #define MOD 1000000007 using lli = long long int; using ulli = unsigned long long int; //#define EVEL 1 #ifndef EVEL #define dbug(X) std::cout << #X << ":" <<X<<" " ; #define dbugf(s) std::cout << s << " "; #define dbugln std::cout<<"\n"; #else #define dbug(X) {} #define dbugf(s) {} #define dbugln {} #endif lli N, W; lli buf, bw; lli P[2][100]; lli mem[400][100][100]; lli DP(lli wei, int num, int use, lli val);//重量, 番号 int main(){ cin >> N >> W; for(int l = 0; l < 400; l++){ for(int m = 0; m < 100; m++){ for(int n = 0; n < 100; n++){ mem[l][m][n] = -1; } } } for(int l = 0;l < N; l++){ cin >> P[0][l] >> P[1][l]; if(l == 0){ bw = P[0][0]; } P[0][l] = P[0][l] - bw + 1; mem[P[0][l]][l][1] = P[1][l]; } cout << DP(0, -1, 0, 0); #include<iostream> #include<vector> #include<algorithm> using namespace std; #define MOD 1000000007 using lli = long long int; using ulli = unsigned long long int; //#define EVEL 1 #ifndef EVEL #define dbug(X) std::cout << #X << ":" <<X<<" " ; #define dbugf(s) std::cout << s << " "; #define dbugln std::cout<<"\n"; #else #define dbug(X) {} #define dbugf(s) {} #define dbugln {} #endif lli N, W; lli buf, bw; lli P[2][100]; lli mem[400][100][100]; lli DP(lli wei, int num, int use, lli val);//重量, 番号 int main(){ cin >> N >> W; for(int l = 0; l < 400; l++){ for(int m = 0; m < 100; m++){ for(int n = 0; n < 100; n++){ mem[l][m][n] = -1; } } } for(int l = 0;l < N; l++){ cin >> P[0][l] >> P[1][l]; if(l == 0){ bw = P[0][0]; } P[0][l] = P[0][l] - bw + 1; mem[P[0][l]][l][1] = P[1][l]; } cout << DP(0, -1, 0, 0); return 0; } lli DP(lli wei, int num, int use, lli val){ dbug(wei); dbug(num); dbug(use); dbug(val); dbugf(" "); dbugln; lli h1, h2, get; if(num == N-1){ mem[wei][num][use] = val; get = val; }else if(mem[wei][num][use] != -1){ if(val > mem[wei][num][use]){ mem[wei][num][use] = val; } get = mem[wei][num][use]; }else{ if( ( wei + P[0][num+1] + (use + 1) * bw ) <= W){ h1 = DP(wei + P[0][num+1], num+1, use+1, val + P[1][num+1]); } h2 = DP(wei, num+1, use, val); get = max(h1, h2); mem[wei][num][use] = get; } dbug(get); dbugln; return get; } return 0; } lli DP(lli wei, int num, int use, lli val){ //dbug(wei); //dbug(num); //dbug(use); //dbug(val); //dbugf(" "); //dbugln; lli h1, h2, get; if(num == N-1){ mem[wei][num][use] = val; get = val; }else if(mem[wei][num][use] != -1){ if(val > mem[wei][num][use]){ mem[wei][num][use] = val; } get = mem[wei][num][use]; }else{ if( ( wei + P[0][num+1] + (use + 1) * bw ) <= W){ h1 = DP(wei + P[0][num+1], num+1, use+1, val + P[1][num+1]); } h2 = DP(wei, num+1, use, val); get = max(h1, h2); mem[wei][num][use] = get; } //dbug(get); //dbugln; return get; }
a.cc: In function 'int main()': a.cc:82:11: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 82 | int main(){ | ^~ a.cc:82:11: note: remove parentheses to default-initialize a variable 82 | int main(){ | ^~ | -- a.cc:82:11: note: or replace parentheses with braces to value-initialize a variable a.cc:82:13: error: a function-definition is not allowed here before '{' token 82 | int main(){ | ^ a.cc:106:45: error: a function-definition is not allowed here before '{' token 106 | lli DP(lli wei, int num, int use, lli val){ | ^
s376660124
p03732
C++
#include <iostream> #include <algorithm> #include <cmath> #include <string> #include <array> #include <vector> #include <functional> #include <numeric> #include <limits> #include <utility> using namespace std; long long n, W; vector<long long> w(100); vector<long long> v(100); vector< vector<long long> > dp(101, vector<long long>(101)); long long dpp(long long, long long); int main(void) { long long i, j; cin >> n >> W; vector< vector<long long> > m(101, vector<long long>(101)); for (i = 0; i < n; i++) { cin >> w[i] >> v[i]; } for (int i = 0; i < 101; i++) { for (int j = 0; j < 101; j++) { dp[i][j] = -1; } } for (int i = n - 1; i >= 0; i--) { for (int j = 0; j <= W; j++) { if (j < w[i]) dp[i][j] = dp[i + 1][j]; else dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]); } } cout << dpp(0,W) << endl; return 0; }
/usr/bin/ld: /tmp/ccu5IXZd.o: in function `main': a.cc:(.text+0x326): undefined reference to `dpp(long long, long long)' collect2: error: ld returned 1 exit status
s714808788
p03732
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; #define MOD 1000000007 using lli = long long int; using ulli = unsigned long long int; //#define EVEL 1 #ifndef EVEL #define dbug(X) std::cout << #X << ":" <<X<<" " ; #define dbugf(s) std::cout << s << " "; #define dbugln std::cout<<"\n"; #else #define dbug(X) {} #define dbugf(s) {} #define dbugln {} #endif lli N, W; lli buf, bw; lli P[2][100]; lli mem[400][100][100]; lli DP(lli wei, int num, int use, lli val);//重量, 番号 int main(){ cin >> N >> W; for(int l = 0; l < 400; l++){ for(int m = 0; m < 100; m++){ for(int n = 0; n < 100; n++){ mem[l][m][n] = -1; } } } for(int l = 0;l < N; l++){ cin >> P[0][l] >> P[1][l]; if(l == 0){ bw = P[0][0]; } P[0][l] = P[0][l] - bw + 1; mem[P[0][l]][l][1] = P[1][l]; } cout << DP(0, -1, 0, 0); #include<iostream> #include<vector> #include<algorithm> using namespace std; #define MOD 1000000007 using lli = long long int; using ulli = unsigned long long int; #define EVEL 1 #ifndef EVEL #define dbug(X) std::cout << #X << ":" <<X<<" " ; #define dbugf(s) std::cout << s << " "; #define dbugln std::cout<<"\n"; #else #define dbug(X) {} #define dbugf(s) {} #define dbugln {} #endif lli N, W; lli buf, bw; lli P[2][100]; lli mem[400][100][100]; lli DP(lli wei, int num, int use, lli val);//重量, 番号 int main(){ cin >> N >> W; for(int l = 0; l < 400; l++){ for(int m = 0; m < 100; m++){ for(int n = 0; n < 100; n++){ mem[l][m][n] = -1; } } } for(int l = 0;l < N; l++){ cin >> P[0][l] >> P[1][l]; if(l == 0){ bw = P[0][0]; } P[0][l] = P[0][l] - bw + 1; mem[P[0][l]][l][1] = P[1][l]; } cout << DP(0, -1, 0, 0); return 0; } lli DP(lli wei, int num, int use, lli val){ dbug(wei); dbug(num); dbug(use); dbug(val); dbugf(" "); dbugln; lli h1, h2, get; if(num == N-1){ mem[wei][num][use] = val; get = val; }else if(mem[wei][num][use] != -1){ if(val > mem[wei][num][use]){ mem[wei][num][use] = val; } get = mem[wei][num][use]; }else{ if( ( wei + P[0][num+1] + (use + 1) * bw ) <= W){ h1 = DP(wei + P[0][num+1], num+1, use+1, val + P[1][num+1]); } h2 = DP(wei, num+1, use, val); get = max(h1, h2); mem[wei][num][use] = get; } dbug(get); dbugln; return get; } return 0; } lli DP(lli wei, int num, int use, lli val){ dbug(wei); dbug(num); dbug(use); dbug(val); dbugf(" "); dbugln; lli h1, h2, get; if(num == N-1){ mem[wei][num][use] = val; get = val; }else if(mem[wei][num][use] != -1){ if(val > mem[wei][num][use]){ mem[wei][num][use] = val; } get = mem[wei][num][use]; }else{ if( ( wei + P[0][num+1] + (use + 1) * bw ) <= W){ h1 = DP(wei + P[0][num+1], num+1, use+1, val + P[1][num+1]); } h2 = DP(wei, num+1, use, val); get = max(h1, h2); mem[wei][num][use] = get; } dbug(get); dbugln; return get; }
a.cc:69:11: warning: "dbug" redefined 69 | #define dbug(X) {} | ^~~~ a.cc:15:9: note: this is the location of the previous definition 15 | #define dbug(X) std::cout << #X << ":" <<X<<" " ; | ^~~~ a.cc:70:11: warning: "dbugf" redefined 70 | #define dbugf(s) {} | ^~~~~ a.cc:16:9: note: this is the location of the previous definition 16 | #define dbugf(s) std::cout << s << " "; | ^~~~~ a.cc:71:11: warning: "dbugln" redefined 71 | #define dbugln {} | ^~~~~~ a.cc:17:9: note: this is the location of the previous definition 17 | #define dbugln std::cout<<"\n"; | ^~~~~~ a.cc: In function 'int main()': a.cc:82:11: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 82 | int main(){ | ^~ a.cc:82:11: note: remove parentheses to default-initialize a variable 82 | int main(){ | ^~ | -- a.cc:82:11: note: or replace parentheses with braces to value-initialize a variable a.cc:82:13: error: a function-definition is not allowed here before '{' token 82 | int main(){ | ^ a.cc:106:45: error: a function-definition is not allowed here before '{' token 106 | lli DP(lli wei, int num, int use, lli val){ | ^
s674035229
p03732
C++
#include <iostream> #include <algorithm> #include <cstdio> #define Max(a,b) a>b?a:b #define INF 10000000000000000 using namespace std; typedef long long LL; const int MAX = 45; LL weight[MAX], value[MAX]; LL W; pair<LL, LL> ps[1 << (MAX / 2)]; int n; void slove() { //枚举前半部分 int n2 = n / 2; for (int i = 0; i < 1 << n2; i++)//前半部分的枚举总数为 2^(n/2); { LL sw = 0, sv = 0; //每种结果选取特定的价值和重量(i.e 一共2个东西,就一共四种情况,都不选,选第一个,选第二个,都选) for (int j = 0; j < n2; j++) { if (i >> j & 1) { sw += weight[j]; sv += value[j]; } } ps[i] = make_pair(sw, sv);//加入到ps数组中 } //对ps排序 sort(ps, ps + (1 << n2)); //ps 去重 int m = 1; for (int i = 1; i < 1 << n2; i++) if (ps[m - 1].second < ps[i].second) ps[m++] = ps[i]; LL res = 0;//保存结果 //枚举后半部分, 并且找到最优解 for (int i = 0; i < 1 << (n - n2); i++)//同样枚举的总个数 { LL sw = 0, sv = 0; for (int j = 0; j < n - n2; j++)//和前半部分的一样 { if (i >> j & 1) { sw += weight[n2 + j]; sv += value[n2 + j]; } } if (sw <= W)//加个判断求解最大价值,只有小于背包容量的时候 { LL tv = (lower_bound(ps, ps + m, make_pair(W - sw, INF)) - 1)->second;//找到前半部分对应的value res = Max(res, sv + tv); } } printf("%lld\n", res); } int main() { while (~scanf("%d %lld", &n, &W)) { for (int i = 0; i < n; i++) scanf("%lld %lld", &weight[i], &value[i]); slove(); } return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:53:37: required from here 53 | LL tv = (lower_bound(ps, ps + m, make_pair(W - sw, INF)) - 1)->second;//找到前半部分对应的value | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3901:5: note: candidate: 'template<class _CharT, c
s987216766
p03732
C++
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=a;i<b;i++) #define REP(i,b) FOR(i,0,b) #define INF 1e9 int N,W,w[100],v[100],dp[100][10000]; int rec(int i,int j){ if (dp[i][j] >= 0) { return dp[i][j]; } int res; if (i == N) { res = 0; } else if (j < w[i]) { res = rec(i+1,j); } else { res = max(rec(i+1,j), rec(i+1,j-w[i])+v[i]); } return dp[i][j] = res; } void solve(){ menset(dp,-1,sizeof(dp)); printf("%d\n", rec(0, W)); } int main(){ cin>>N>>W; REP(i,N){ cin>>w[i]>>v[i]; } return 0; }
a.cc: In function 'void solve()': a.cc:27:3: error: 'menset' was not declared in this scope; did you mean 'memset'? 27 | menset(dp,-1,sizeof(dp)); | ^~~~~~ | memset
s485574987
p03732
C
#include <stdio.h> void max_value(const int N, const long weight, long w[], long v[], double*ans, double *box, double *rweight, int *a) { int i, b; double bweight = 0; for (i = 0; i + a < N; i++) { b = a; if(rweight + w[i+b] <= weight) { bweight = w[i + b]; rweight += w[i+b]; box += v[i+ b]; a++; max_value(N, weight, w, v, ans, box, rweight, a); } else { if (box > ans) ans = box; } a = 0; rweight -= bweight; } } int main() { int n, a; long weight, i; double ans, box, rweight; rweight = 0; a = 0; scanf("%d %ld", &n, &weight); long w[100], v[100]; for (i = 0; i < n; i++) { scanf("%ld %ld", &w[i], &v[i]); } ans = 0; box = 0; max_value(n, weight, w, v, &ans, &box, &rweight, &a); printf("%ld", ans); return 0; }
main.c: In function 'max_value': main.c:8:27: warning: comparison between pointer and integer 8 | for (i = 0; i + a < N; i++) | ^ main.c:10:19: error: assignment to 'int' from 'int *' makes integer from pointer without a cast [-Wint-conversion] 10 | b = a; | ^ main.c:11:37: warning: comparison between pointer and integer 11 | if(rweight + w[i+b] <= weight) | ^~ main.c:24:25: error: invalid operands to binary - (have 'double *' and 'double') 24 | rweight -= bweight; | ^~
s802823736
p03732
C++
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for (int i=0;i<(n);i++) int main(void) { int N, W; cin >> N >> W; int w[N], v[N]; REP(i,N) cin >> w[i] >> v[i]; int dp[N+1][W]; for (int j = 0; j <= W; j++) { dp[N][j] = 0; } for (int i = N - 1; i >= 0; i--) { for (int j = 0; j <= W; j++) { if (j < w[i]) dp[i][j] = dp[i + 1][j]; else dp[i][j] = max(dp[i + 1][j], dp[i + 1][j - w[i]] + v[i]); } } solve_dp(N,W,w,v,dp); cout << dp[0][W] << '\n'; }
a.cc: In function 'int main()': a.cc:25:3: error: 'solve_dp' was not declared in this scope 25 | solve_dp(N,W,w,v,dp); | ^~~~~~~~
s654140303
p03732
C++
#include<stdio.h> #include<iostream> #include<string> #include<vector> #include<map> #include<list> #include<queue> #include<deque> #include<algorithm> #include<utility> #include<memory> #include<cmath> #define ALL(g) (g).begin(),(g).end() #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define pb push_back using namespace std; typedef long long ll; typedef pair<int,int> P; const int mod=1e9+7,INF=1<<30; const double EPS=1e-12,PI=3.1415926535897932384626; const int MAX_N=102,MAX_W=100002; ll dp[MAX_N][MAX_W]; int N; ll W; ll w[MAX_N],v[MAX_N]; void calc(){ fill(dp[0],dp[N+1],0); rep(i,N){ rep(j,W+1){ dp[i+1][j]=max(dp[i+1][j],dp[i][j]); if(j+w[i]<=W){ dp[i+1][j+w[i]]=max(dp[i+1][j+w[i]],dp[i][j]+v[i]); } } } return; } int main(){ cin >> N >> W ; ll temp=0; int N2=0; rep(i,N){ ll a,b; scanf("%lld%lld",&a,&b); if(a<=W){ N2++; w[i]=a; v[i]=b; temp=max(temp,a); } } N=N2; if(W<MAX_W-2){ calc(); printf("%lld\n",dp[N][W]); }else{ W/=temp; cout << W << endl; rep(i,N){ w[i]=(w[i]+temp-1)/temp; cout << w[i] << endl; } if(W<MAX_W-2){ calc(); printf("%lld\n",dp[N][W]); }else{ ll S=0; rep(i,N) S+=v[i]; printf("%lld\n",S); // sort(v,v+N); // reverse(v,v+N); // ll S=0; // rep(i,min(W,(ll)N)){ // S+=v[i]; // } // printf("%lld\n",S); } return 0; }
a.cc: In function 'int main()': a.cc:86:2: error: expected '}' at end of input 86 | } | ^ a.cc:45:11: note: to match this '{' 45 | int main(){ | ^
s596347117
p03732
C++
#pragma comment(linker, "/STACK:36777216") #include <bits/stdc++.h> using namespace std; #define LSON id << 1 , l , mid #define RSON id << 1 | 1 , mid + 1 , r #define ROOT 1 , 1 , n #define CLR(x , y) memset(x , y , sizeof(x)) #define LOWBIT(x) x & (-x) #define FORN(i , a , n) for(int i = (a) ; i <= (n) ; ++i) #define FORP(i , n , a) for(int i = (n) ; i >= (a) ; --i) #define CASE(x) printf("Case %d: ", x) #define SFD(x) scanf("%lf" , &x) #define SFC(x) scanf(" %c" , &x) #define SFS(x) scanf(" %s" , x) #define SFI(x) scanf("%d" , &x) #define SFL(x) scanf("%lld" , &x) #define SFI64(x) scanf("%I64d" , &x) #define PFF(x) printf("%f" , x) #define PFD(x) printf("%lf" , x) #define PFI(x) printf("%d" , x) #define PFC(x) printf("%c" , x) #define PFS(x) printf("%s" , x) #define PFI64(x) printf("%I64d" , x) #define PFL(x) printf("%lld" , x) #define SPACE printf(" ") #define PUT puts("") #define LPUP(i , j , k) for(int i = j ; i <= k ; ++i) #define LPDW(i , j , k) for(int i = j ; i >= k ; --i) #define PB(x) push_back(x) #define ALL(A) A.begin(), A.end() #define SZ(A) int((A).size()) #define LBD(A, x) (lower_bound(ALL(A), x) - A.begin()) #define UBD(A, x) (upper_bound(ALL(A), x) - A.begin()) #define LOCAL static const double PI = acos(-1.0); static const double EPS = 1e-8; static const int INF = 0X3fffffff; typedef __int64 LL; typedef double DB; template<class T> inline T read(T &x) { x = 0; int f = 1 ; char ch = getchar(); while (ch < '0' || ch > '9') {if (ch == '-') f = -1; ch = getchar();} while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();} x *= f; } /************************Little Pea****************************/ LL t; int n; LL p; LL now; int main() { #ifndef ONLINE_JUDGE //freopen("D:\\系统优化\\Desktop\\littlepea\\in.data" , "r" , stdin); #endif read(n);read(t); LL pre = 0; LPUP(i , 1 , n) { read(p); if(p >= now) { now += t; } else { now += (p - pre); } pre = p; } PFI64(now); #ifndef ONLINE_JUDGE fclose(stdin), fclose(stdout); #endif }
a.cc:39:9: error: '__int64' does not name a type; did you mean '__int64_t'? 39 | typedef __int64 LL; | ^~~~~~~ | __int64_t a.cc:53:1: error: 'LL' does not name a type; did you mean 'ALL'? 53 | LL t; | ^~ | ALL a.cc:55:1: error: 'LL' does not name a type; did you mean 'ALL'? 55 | LL p; | ^~ | ALL a.cc:56:1: error: 'LL' does not name a type; did you mean 'ALL'? 56 | LL now; | ^~ | ALL a.cc: In function 'int main()': a.cc:62:18: error: 't' was not declared in this scope; did you mean 'tm'? 62 | read(n);read(t); | ^ | tm a.cc:63:5: error: 'LL' was not declared in this scope; did you mean 'ALL'? 63 | LL pre = 0; | ^~ | ALL a.cc:66:14: error: 'p' was not declared in this scope 66 | read(p); | ^ a.cc:67:17: error: 'now' was not declared in this scope; did you mean 'pow'? 67 | if(p >= now) | ^~~ | pow a.cc:73:25: error: 'pre' was not declared in this scope; did you mean 'pread'? 73 | now += (p - pre); | ^~~ | pread a.cc:75:9: error: 'pre' was not declared in this scope; did you mean 'pread'? 75 | pre = p; | ^~~ | pread a.cc:77:11: error: 'now' was not declared in this scope; did you mean 'pow'? 77 | PFI64(now); | ^~~ a.cc:24:41: note: in definition of macro 'PFI64' 24 | #define PFI64(x) printf("%I64d" , x) | ^ a.cc: In instantiation of 'T read(T&) [with T = int]': a.cc:62:9: required from here 62 | read(n);read(t); | ~~~~^~~ a.cc:49:1: warning: no return statement in function returning non-void [-Wreturn-type] 49 | } | ^
s000650368
p03732
C++
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=a;i<b;i++) #define REP(i,b) FOR(i,0,b) #define INF 1e9 int N,W,w[100],v[100],dp[100][10000]; cin>>N>>W; REP(i,N){ cin>>w[i]>>v[i]; } int rec(int i,int j){ if (dp[i][j] >= 0) { return dp[i][j]; } int res; if (i == N) { res = 0; } else if (j < w[i]) { res = rec(i+1,j); } else { res = max(rec(i+1,j), rec(i+1,j-w[i])+v[i]); } return dp[i][j] = res; } void solve(){ menset(dp,-1,sizeof(dp)); printf("%d\n", rec(0, W)); } int main(){ return 0; }
a.cc:9:1: error: 'cin' does not name a type 9 | cin>>N>>W; | ^~~ a.cc:3:20: error: expected unqualified-id before 'for' 3 | #define FOR(i,a,b) for(int i=a;i<b;i++) | ^~~ a.cc:4:18: note: in expansion of macro 'FOR' 4 | #define REP(i,b) FOR(i,0,b) | ^~~ a.cc:11:1: note: in expansion of macro 'REP' 11 | REP(i,N){ | ^~~ a.cc:11:5: error: 'i' does not name a type 11 | REP(i,N){ | ^ a.cc:3:32: note: in definition of macro 'FOR' 3 | #define FOR(i,a,b) for(int i=a;i<b;i++) | ^ a.cc:11:1: note: in expansion of macro 'REP' 11 | REP(i,N){ | ^~~ a.cc:11:5: error: 'i' does not name a type 11 | REP(i,N){ | ^ a.cc:3:36: note: in definition of macro 'FOR' 3 | #define FOR(i,a,b) for(int i=a;i<b;i++) | ^ a.cc:11:1: note: in expansion of macro 'REP' 11 | REP(i,N){ | ^~~ a.cc: In function 'void solve()': a.cc:33:3: error: 'menset' was not declared in this scope; did you mean 'memset'? 33 | menset(dp,-1,sizeof(dp)); | ^~~~~~ | memset
s897766097
p03732
C++
#include <iostream> #include <string> #include <algorithm> #include <queue> #include <map> #include <set> #include <vector> #include <cmath> #include <cctype> #define rep(i,a,b) for(int (i)=(a);i<(b);i++) #define MAX_N 105 #define MAX_V 10000000 #define INF 10000000 using namespace std; bool debug=false; long long dp[MAX_N][MAX_V+1]; int N,W; int w[MAX_N],v[MAX_V]; long long solve(){ rep(i,0,MAX_N)rep(j,0,MAX_V*MAX_N+1)dp[i][j]=INF; for(int i=0;i<=N;i++)dp[i][0]=0; for(int i=1;i<=N;i++){ for(int j=0;j<MAX_V*MAX_N+1;j++){ if (j-v[i]<0)dp[i][j]=dp[i-1][j]; else dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]); } } long long maxi=0; //for(int i=0;i<=10005;i++)if(dp[N][i]!=INF)cout<<dp[N][i]<<endl; for(int i=0;i<=MAX_N*MAX_V;i++)if(dp[N][i]<=W)maxi=i; return maxi; } int main(){ cin>>N>>W; for(int i=1;i<=N;i++)cin>>w[i]>>v[i]; cout<<solve()<<endl; return 0; }
/tmp/ccPOoeko.o: in function `solve()': a.cc:(.text+0x87): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccPOoeko.o a.cc:(.text+0xb8): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccPOoeko.o a.cc:(.text+0x137): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccPOoeko.o a.cc:(.text+0x176): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccPOoeko.o a.cc:(.text+0x203): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccPOoeko.o a.cc:(.text+0x223): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccPOoeko.o a.cc:(.text+0x24e): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccPOoeko.o /tmp/ccPOoeko.o: in function `main': a.cc:(.text+0x280): relocation truncated to fit: R_X86_64_PC32 against symbol `N' defined in .bss section in /tmp/ccPOoeko.o a.cc:(.text+0x29c): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccPOoeko.o a.cc:(.text+0x2c4): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccPOoeko.o a.cc:(.text+0x2f0): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s918218640
p03732
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define loop(i,a,b) for(i=a;i<b;i++) #define rloop(i,a,b) for(i=a;i>=b;i--) #define vi vector<int> #define vs vector<string> const int inf=1000000001; const ll INF=1e16; #define MOD 1000000007 #define mod 1000000009 #define pi 3.14159265358979323846 int main(){ ll n,w,i,j,k; cin>>n>>w; vector<ll> weight(n),value(n); loop(i,0,n){ cin>>weight[i]>>value[i]; } vector<ll> dp(w+1,-1); dp[0]=0; loop(i,0,n){ rloop(j,w,0){ if(dp[j]!=-1 && j+weight[i]<=w){ dp[j+w[i]]=min(dp[j+weight[i]],dp[j]+value[i]); } } } ll m=0; loop(i,0,w+1){ if(dp[i]!=-1){ m=max(m,dp[i]); } } cout<<m<<endl; }
a.cc: In function 'int main()': a.cc:27:39: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript 27 | dp[j+w[i]]=min(dp[j+weight[i]],dp[j]+value[i]); | ^
s783683870
p03732
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define loop(i,a,b) for(i=a;i<b;i++) #define rloop(i,a,b) for(i=a;i>=b;i--) #define vi vector<int> #define vs vector<string> const int inf=1000000001; const ll INF=1e16; #define MOD 1000000007 #define mod 1000000009 #define pi 3.14159265358979323846 int main(){ int n,w,i,j,k; cin>>n>>w; vi weight(n),value(n); loop(i,0,n){ cin>>weight[i]>>value[i]; } vector<ll> dp(w+1,-1); dp[0]=0; loop(i,0,n){ rloop(j,w,0){ if(dp[j]!=-1 && j+weight[i]<=w){ dp[j+w[i]]=min(dp[j+weight[i]],dp[j]+value[i]); } } } ll m=0; loop(i,0,w+1){ if(dp[i]!=-1){ m=max(m,dp[i]); } } cout<<m<<endl; }
a.cc: In function 'int main()': a.cc:27:39: error: invalid types 'int[int]' for array subscript 27 | dp[j+w[i]]=min(dp[j+weight[i]],dp[j]+value[i]); | ^
s850762453
p03732
C++
#include <iostream> #include <vector> #include <algorithm> #include <stdio.h> #include <string.h> using namespace std; int dp[101][1000000001]; int n,w; vector<int> W(101),V(101); int rec(int i, int j){ if(dp[i][j] >= 0){ return dp[i][j]; } int res; if(i == n){ res = 0; } else if(j< W[i]) { res = rec(i+1, j); } else { res = max(rec(i+1, j), rec(i+1, j-W[i]) + V[i]); } return dp[i][j] = res; } int main(int argc, const char * argv[]) { cin >> n >> w; for (int i=0; i<n; i++) { cin >> W[i] >> V[i]; } memset(dp, -1, sizeof(dp)); cout << rec(0, w); return 0; }
/tmp/ccFxNfi9.o: in function `rec(int, int)': a.cc:(.text+0x68): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccFxNfi9.o a.cc:(.text+0x88): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccFxNfi9.o a.cc:(.text+0xc2): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccFxNfi9.o a.cc:(.text+0xf1): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccFxNfi9.o /tmp/ccFxNfi9.o: in function `main': a.cc:(.text+0x19b): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccFxNfi9.o a.cc:(.text+0x1b7): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccFxNfi9.o a.cc:(.text+0x1da): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccFxNfi9.o a.cc:(.text+0x206): relocation truncated to fit: R_X86_64_PC32 against symbol `V' defined in .bss section in /tmp/ccFxNfi9.o a.cc:(.text+0x223): relocation truncated to fit: R_X86_64_PC32 against symbol `n' defined in .bss section in /tmp/ccFxNfi9.o a.cc:(.text+0x24f): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccFxNfi9.o /tmp/ccFxNfi9.o: in function `__static_initialization_and_destruction_0()': a.cc:(.text+0x29d): additional relocation overflows omitted from the output collect2: error: ld returned 1 exit status
s186888935
p03732
C++
#include <iostream> #include <fstream> #include <cstring> #include <algorithm> #include <vector> using namespace std; struct obj{int val, g;} x,v1[105],a[9]; int l1,l2,b,c,n,T,d[50001],i,gmax,dif,maxi,poz,nrv,nr2,iok,jok,j; long long sumg,sumval; vector<obj> v[5]; bool cmp(obj a, obj b) { return a.g>b.g || (a.g==b.g && a.val<b.val); } int main() { cin>>n>>gmax; cin>>x.g>>x.val; v[0].push_back(x); v1[1]=x; for(i=2;i<=n;i++) { cin>>x.g>>x.val; v1[i]=x; dif=x.g-v[0][0].g; v[dif].push_back(x); } if(gmax<=40000) { d[0]=1; for(i=1;i<=n;i++) { for(poz=gmax-v1[i].g;poz>=0;poz--) { if(d[poz] && d[poz+v1[i].g]<d[poz]+v1[i].val) d[poz+v1[i].g]=d[poz]+v1[i].val; } } for(i=0;i<=gmax;i++) if(d[i]>maxi) maxi=d[i]; cout<<maxi-1<<'\n'; } else { for(i=1;i<=n;i++) sumg+=v1[i].g, sumval+=v1[i].val; if(sumg<=gmax) //cout<<sumval<<'\n'; else { for(i=0;i<=3;i++) sort(v[i].begin(),v[i].end(),cmp); sumval=0; while(gmax>=2*(v1[1].g+3)) { maxi=0; nrv=-1; for(i=0;i<=3;i++) if(!v[i].empty() && v[i].back().val>maxi) maxi=v[i].back().val, nrv=i; sumval+=v[nrv].back().val; gmax-=v[nrv].back().g; v[nrv].pop_back(); } nr2=0; for(i=0;i<=3;i++) { if(v[i].size()==1) a[++nr2]=v[i].back(); if(v[i].size()>=2) { a[++nr2]=v[i].back(); v[i].pop_back(); a[++nr2]=v[i].back(); } } maxi=0; iok=0; jok=0; for(i=1;i<nr2;i++) { for(j=i+1;j<=nr2;j++) { if(a[i].g+a[j].g<=gmax && a[i].val+a[j].val>=maxi) maxi=a[i].val+a[j].val, iok=i, jok=j; } } cout<<sumval+maxi<<'\n'; } } return 0; }
a.cc: In function 'int main()': a.cc:48:9: error: expected primary-expression before 'else' 48 | else | ^~~~
s266393922
p03732
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; int dp[101][101]; int n,w; vector<int> W(101),V(101); int rec(int i, int j){ if(dp[i][j] >= 0){ return dp[i][j]; } int res; if(i == n){ res = 0; } else if(j< W[i]) { res = rec(i+1, j); } else { res = max(rec(i+1, j), rec(i+1, j-W[i]) + V[i]); } return dp[i][j] = res; } int main(int argc, const char * argv[]) { cin >> n >> w; for (int i=0; i<n; i++) { cin >> W[i] >> V[i]; } memset(dp, -1, sizeof(dp)); cout << rec(0, w); return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:30:5: error: 'memset' was not declared in this scope 30 | memset(dp, -1, sizeof(dp)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <algorithm> +++ |+#include <cstring> 4 | using namespace std;
s176066170
p03732
C++
#include <iostream> #include <vector> using namespace std; //table[w][i]:重さw1以上w以下でi番目まで入れたときの最大の価値 int main(){ int N,W; cin>>N>>W; vector<int> weights(N),values(N); for(int i=0;i<N;++i){ cin>>weights[i]>>values[i]; } // int first_weight = weights[0]; // if(first_weight>W){ // cout<<0<<endl; // return 0; // } // for(auto &w:weights) w -= first_weight; // W -= first_weight; // vector<vector<int>> table(W+1,vector<int>(N+1)); for(int w=1;w<=W;++w){ for(int i=1;i<=N;++i){ if(w<weights[i-1]){ table[w][i] = table[w][i-1]; }else{ table[w][i] = max(table[w-weights[i-1]][i-1]+values[i-1],table[w][i-1]); } } } cout<<table[W][N]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:26:9: error: 'table' was not declared in this scope; did you mean 'mutable'? 26 | table[w][i] = table[w][i-1]; | ^~~~~ | mutable a.cc:28:9: error: 'table' was not declared in this scope; did you mean 'mutable'? 28 | table[w][i] = max(table[w-weights[i-1]][i-1]+values[i-1],table[w][i-1]); | ^~~~~ | mutable a.cc:32:9: error: 'table' was not declared in this scope; did you mean 'mutable'? 32 | cout<<table[W][N]<<endl; | ^~~~~ | mutable
s055819432
p03732
C++
#include <iostream> #include <vector> using namespace std; int dp[101][101]; int n,w; vector<int> W(101),V(101); int rec(int i, int j){ if(dp[i][j] >= 0){ return dp[i][j]; } int res; if(i == n){ res = 0; } else if(j< W[i]) { res = rec(i+1, j); } else { res = max(rec(i+1, j), rec(i+1, j-W[i]) + V[i]); } return dp[i][j] = res; } int main(int argc, const char * argv[]) { cin >> n >> w; for (int i=0; i<n; i++) { cin >> W[i] >> V[i]; } memset(dp, -1, sizeof(dp)); cout << rec(0, w); return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:30:5: error: 'memset' was not declared in this scope 30 | memset(dp, -1, sizeof(dp)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <vector> +++ |+#include <cstring> 3 |
s144618515
p03732
C++
#include"bits/stdc++.h" //#include<bits/stdc++.h> using namespace std; #define rep(i,a,b) for(int i=a;i<=b;i++) #define print(x) cout<<x<<endl; typedef long long ll; int N; ll W; ll w[105], v[105]; ll table[102][1000002]; ll dp(int now, ll mergin) { ll sum = 0; if (table[now][mergin] != -1) return table[now][mergin]; if (now == N) { sum = 0; } else if (mergin < w[now]) { sum = 0; } else { sum = max(dp(now + 1, mergin), dp(now + 1, mergin - w[now]) + v[now]); } return table[now][mergin] = sum; } int main() { memset(dp, -1, sizeof(table)); cin >> N >> W; rep(i, 0, N) cin >> w[i] >> v[i]; print(dp(0,W)); }
a.cc: In function 'int main()': a.cc:25:16: error: invalid conversion from 'll (*)(int, ll)' {aka 'long long int (*)(int, long long int)'} to 'void*' [-fpermissive] 25 | memset(dp, -1, sizeof(table)); | ^~ | | | ll (*)(int, ll) {aka long long int (*)(int, long long int)} In file included from /usr/include/c++/14/cstring:43, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121, from a.cc:1: /usr/include/string.h:61:28: note: initializing argument 1 of 'void* memset(void*, int, size_t)' 61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); | ~~~~~~^~~
s683534912
p03732
C++
#include <iostream> #include <vector> #include <algorithm> #include <string.h> using namespace std; const int MAX_N = 1000; // nの最大値 const int MAX_W = 1000000007; // Wの最大値 // 入力 int n, W; int w[MAX_N], v[MAX_N]; // i番目以降の品物から重さの和がj以下なるように選んだときの、 // 取りうる価値の総和の最大値を返す関数 int rec(int i, int j) { int res; if (i == n) { // 品物がもう残っていないときは、価値の和の最大値は0で確定 res = 0; } else if (j < w[i]) { // 残りの容量が足りず品物iを入れられないので、入れないパターンだけ処理 // i+1 以降の品物で判定したときの最大値をそのままこの場合の最大値にする res = rec(i + 1, j); } else { // 品物iを入れるか入れないか選べるので、両方試して価値の和が大きい方を選ぶ res = max( rec(i + 1, j), rec(i + 1, j - w[i]) + v[i] ); } return res; } // 単純な再帰を用いた解法 void solve() { // 0番目以降で容量W以下の場合の結果を表示する cout << rec(0, W) << endl; } // メモ化テーブル // dp[i][j]はi番目以降の品物から重さの和がj以下なるように選んだときの価値の和の最大値を表す。 // -1なら値が未決定であることを表す int dp[MAX_N + 1][MAX_W + 1]; // i番目以降の品物から重さの和がj以下なるように選んだときの、 // 取りうる価値の総和の最大値を返す関数。メモ配列で計算結果を再利用する int rec_dp(int i, int j) { if (dp[i][j] != -1) { // すでに調べたことがあるならその結果を再利用 return dp[i][j]; } int res; if (i == n) { // 品物がもう残っていないときは、価値の和の最大値は0で確定 res = 0; } else if (j < w[i]) { // 残りの容量が足りず品物iを入れられないので、入れないパターンだけ処理 res = rec_dp(i + 1, j); } else { // 品物iを入れるか入れないか選べるので、両方試して価値の和が大きい方を選ぶ res = max( rec_dp(i + 1, j), rec_dp(i + 1, j - w[i]) + v[i] ); } // 結果をテーブルに記憶する return dp[i][j] = res; } // メモ化再帰を用いた解法 void solve_dp() { memset(dp, -1, sizeof(dp)); // メモ化テーブルを-1で初期化 以下のforループと等価 // for (int i = 0; i < MAX_N + 1; i++) // for (int j = 0; j < MAX_W + 1; j++) // dp[i][j] = -1; // 0番目以降で容量W以下の場合の結果を表示する cout << rec_dp(0, W) << endl; } // DPテーブル。 // dp2[i][j]はi番目以降の品物から重さの和がj以下なるように選んだときの価値の和の最大値を表す。 int dp2[MAX_N + 1][MAX_W + 1]; // 漸化式を用いた解法 void solve_dp2() { for (int j = 0; j <= W; j++) dp2[n][j] = 0; for (int i = n - 1; i >= 0; i--) { for (int j = 0; j <= W; j++) { if (j < w[i]) dp2[i][j] = dp2[i + 1][j]; else dp2[i][j] = max(dp2[i + 1][j], dp2[i + 1][j - w[i]] + v[i]); } } cout << dp2[0][W] << endl; } int main() { cin >> n >> W; for (int i = 0; i < n; i++) { cin >> w[i] >> v[i]; } solve_dp2(); // 漸化式ループによるDP return 0; }
/tmp/cc9GIx6K.o: in function `solve_dp2()': a.cc:(.text+0x317): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/cc9GIx6K.o a.cc:(.text+0x38d): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/cc9GIx6K.o a.cc:(.text+0x3b5): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/cc9GIx6K.o a.cc:(.text+0x3fe): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/cc9GIx6K.o a.cc:(.text+0x445): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/cc9GIx6K.o a.cc:(.text+0x47e): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/cc9GIx6K.o a.cc:(.text+0x4b9): relocation truncated to fit: R_X86_64_PC32 against symbol `dp2' defined in .bss section in /tmp/cc9GIx6K.o collect2: error: ld returned 1 exit status
s850315626
p03732
C++
#include <iostream> #include <algorithm> #include <cstdio> #define Max(a,b) a>b?a:b #define INF 10000000000000000 using namespace std; typedef long long LL; const int MAX = 110; LL weight[MAX], value[MAX]; LL W; pair<LL, LL> ps[1 << (MAX / 2)]; int n; void slove() { //枚举前半部分 int n2 = n / 2; for (int i = 0; i < 1 << n2; i++)//前半部分的枚举总数为 2^(n/2); { LL sw = 0, sv = 0; //每种结果选取特定的价值和重量(i.e 一共2个东西,就一共四种情况,都不选,选第一个,选第二个,都选) for (int j = 0; j < n2; j++) { if (i >> j & 1) { sw += weight[j]; sv += value[j]; } } ps[i] = make_pair(sw, sv);//加入到ps数组中 } //对ps排序 sort(ps, ps + (1 << n2)); //ps 去重 int m = 1; for (int i = 1; i < 1 << n2; i++) if (ps[m - 1].second < ps[i].second) ps[m++] = ps[i]; LL res = 0;//保存结果 //枚举后半部分, 并且找到最优解 for (int i = 0; i < 1 << (n - n2); i++)//同样枚举的总个数 { LL sw = 0, sv = 0; for (int j = 0; j < n - n2; j++)//和前半部分的一样 { if (i >> j & 1) { sw += weight[n2 + j]; sv += value[n2 + j]; } } if (sw <= W)//加个判断求解最大价值,只有小于背包容量的时候 { LL tv = (lower_bound(ps, ps + m, make_pair(W - sw, INF)) - 1)->second;//找到前半部分对应的value res = Max(res, sv + tv); } } printf("%lld\n", res); } int main() { while (~scanf("%d %lld", &n, &W)) { for (int i = 0; i < n; i++) scanf("%lld %lld", &weight[i], &value[i]); slove(); } return 0; }
a.cc:11:19: warning: left shift count >= width of type [-Wshift-count-overflow] 11 | pair<LL, LL> ps[1 << (MAX / 2)]; | ~~^~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]': /usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 1504 | if (__comp(__middle, __val)) | ~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]' 1539 | return std::__lower_bound(__first, __last, __val, | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~ 1540 | __gnu_cxx::__ops::__iter_less_val()); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:53:33: required from here 53 | LL tv = (lower_bound(ps, ps + m, make_pair(W - sw, INF)) - 1)->second;//找到前半部分对应的value | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int') 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | { return *__it < __val; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 69 | {