Language: Java

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;



int N, ga, sa, ba, gb, sb, bb;
int dp[4][5050];
vector<P>p;
bool cmp(const P& p1, const P& p2) {
	return (p1.second - p1.first) < (p2.second - p1.first);
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N >> ga>> sa>> ba>> gb>> sb>> bb;
	REP(i, 4) {
		REP(j, 5050)dp[i][j] = 0;
	}
	p.push_back({ ga,gb });
	p.push_back({ ba,bb });
	p.push_back({ sa,sb });
	sort(p.begin(), p.end(), cmp);
	REP(i, 3) {
		//pe(p[i].first)print(p[i].second);
	}//cout << endl;
	//全部Aの方が高い場合
	if (p[2].second - p[2].first <= 0) {
		int wei[3], val[3];
		REP(i, 3) {
			val[i] = p[i].first;
			wei[i] = p[i].second;
		}
		REP(i, 3) {
			REP(w, N + 1) {
				//pe(i)pe(w);
				//pe("val:")pe(val[i]);
				dp[i + 1][w] = max(dp[i + 1][w], dp[i][w]);
				if (w >= wei[i]) {
					//print(dp[i + 1][w - wei[i]]);
					dp[i + 1][w] = max(dp[i + 1][w], dp[i + 1][w - wei[i]] + val[i]);
				}
				//print(dp[i + 1][w]);
			}
		}
		print(dp[3][N]); return 0;
	}
	else if (p[0].second - p[0].first >= 0) {
		//print("allB");
		int wei[3], val[3];
		REP(i, 3) {
			wei[i] = p[i].first;
			val[i] = p[i].second;
		}
		REP(i, 3) {
			REP(w, N+1) {
				//pe(i)pe(w);
				//pe("val:")pe(val[i]);
				dp[i + 1][w] = max(dp[i + 1][w], dp[i][w]);
				if (w >= wei[i]) {
					//print(dp[i + 1][w - wei[i]]);
					dp[i + 1][w] = max(dp[i + 1][w], dp[i + 1][w - wei[i]] + val[i]);
				}
				//print(dp[i + 1][w]);
			}
		}
		print(dp[3][N]); return 0;
	}
	//Aでp[2]を変えるだけ
	else if (p[1].second <= p[1].first) {
		int cnt = N / p[2].first;
		N -= cnt * p[2].first;
		N += cnt * p[2].second;
		//print(N);
		int ans = 0;
		REP(i, N+1) {
			REP(j, N+1) {
				if (i*p[0].second + j * p[1].second > N)break;
				int res = i * p[0].first + j * p[1].first + N - (i*p[0].second + j * p[1].second);
				ans = max(ans, res);
			}
		}
		print(ans);
	}
	else {
		int N2 = N;
		REP(i, N+1) {
			REP(j, N+1) {
				if (i*p[1].first + j * p[2].first > N)break;
				int res = i * p[1].second + j * p[2].second + N - (i*p[1].first + j * p[2].first);
				N2 = max(N2, res);
			}
		}
		int cnt = N2 / p[0].second;
		N2 -= cnt * p[0].second;
		N2 += cnt * p[0].first;
		print(N2);
	}
}


Compiler output:
Main.java:1: error: illegal character: '#'
#include<iostream>
^
Main.java:2: error: illegal character: '#'
#include<string>
^
Main.java:3: error: illegal character: '#'
#include<algorithm>
^
Main.java:4: error: illegal character: '#'
#include<vector>
^
Main.java:5: error: illegal character: '#'
#include<queue>
^
Main.java:6: error: illegal character: '#'
#include<map>
^
Main.java:7: error: illegal character: '#'
#include<math.h>
^
Main.java:8: error: illegal character: '#'
#include<iomanip>
^
Main.java:9: error: illegal character: '#'
#include<set>
^
Main.java:10: error: illegal character: '#'
#include<numeric>
^
Main.java:11: error: illegal character: '#'
#include<cstring>
^
Main.java:12: error: illegal character: '#'
#include<cstdio>
^
Main.java:13: error: illegal character: '#'
#include<functional>
^
Main.java:14: error: illegal character: '#'
#include<bitset>
^
Main.java:15: error: illegal character: '#'
#include<limits.h>
^
Main.java:16: error: illegal character: '#'
#include<cassert>
^
Main.java:17: error: illegal character: '#'
#include <fstream>
^
Main.java:18: error: illegal character: '#'
#include <time.h>
^
Main.java:19: error: illegal character: '#'
#include <iterator>
^
Main.java:22: error: illegal character: '#'
#define REP(i, n) for(int i = 0;i < n;i++)
^
Main.java:22: error: class, interface, enum, or record expected
#define REP(i, n) for(int i = 0;i < n;i++)
                                ^
Main.java:22: error: class, interface, enum, or record expected
#define REP(i, n) for(int i = 0;i < n;i++)
                                      ^
Main.java:23: error: illegal character: '#'
#define REPR(i, n) for(int i = n;i >= 0;i--)
^
Main.java:23: error: class, interface, enum, or record expected
#define REPR(i, n) for(int i = n;i >= 0;i--)
                                 ^
Main.java:23: error: class, interface, enum, or record expected
#define REPR(i, n) for(int i = n;i >= 0;i--)
                                        ^
Main.java:24: error: illegal character: '#'
#define FOR(i, m, n) for(int i = m;i < n;i++)
^
Main.java:24: error: class, interface, enum, or record expected
#define FOR(i, m, n) for(int i = m;i < n;i++)
                                   ^
Main.java:24: error: class, interface, enum, or record expected
#define FOR(i, m, n) for(int i = m;i < n;i++)
                                         ^
Main.java:25: error: illegal character: '#'
#define FORR(i, m, n) for(int i = m;i >= n;i--)
^
Main.java:25: error: class, interface, enum, or record expected
#define FORR(i, m, n) for(int i = m;i >= n;i--)
                                    ^
Main.java:25: error: class, interface, enum, or record expected
#define FORR(i, m, n) for(int i = m;i >= n;i--)
                                           ^
Main.java:26: error: illegal character: '#'
#define SORT(v, n) sort(v, v+n);
^
Main.java:27: error: illegal character: '#'
#define VSORT(v) sort(v.begin(), v.end());
^
Main.java:27: error: class, interface, enum, or record expected
#define VSORT(v) sort(v.begin(), v.end());
        ^
Main.java:28: error: illegal character: '#'
#define REVERSE(v,n) reverse(v,v+n);
^
Main.java:28: error: class, interface, enum, or record expected
#define REVERSE(v,n) reverse(v,v+n);
        ^
Main.java:29: error: illegal character: '#'
#define VREVERSE(v) reverse(v.begin(), v.end());
^
Main.java:29: error: class, interface, enum, or record expected
#define VREVERSE(v) reverse(v.begin(), v.end());
        ^
Main.java:30: error: illegal character: '#'
#define ll long long
^
Main.java:30: error: class, interface, enum, or record expected
#define ll long long
        ^
Main.java:31: error: illegal character: '#'
#define pb(a) push_back(a)
^
Main.java:32: error: illegal character: '#'
#define m0(x) memset(x,0,sizeof(x))
^
Main.java:33: error: illegal character: '#'
#define print(x) cout<<x<<endl;
^
Main.java:34: error: illegal character: '#'
#define pe(x) cout<<x<<" ";
^
Main.java:34: error: class, interface, enum, or record expected
#define pe(x) cout<<x<<" ";
        ^
Main.java:35: error: illegal character: '#'
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
^
Main.java:35: error: class, interface, enum, or record expected
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
        ^
Main.java:36: error: illegal character: '#'
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
^
Main.java:36: error: class, interface, enum, or record expected
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
        ^
Main.java:37: error: illegal character: '#'
#define int long long
^
Main.java:37: error: class, interface, enum, or record expected
#define int long long
        ^
Main.java:38: error: illegal character: '#'
#define all(x) (x).begin(), (x).end()
^
Main.java:42: error: unnamed classes are a preview feature and are disabled by default.
int MOD = (ll)1000000000 + 7;
^
  (use --enable-preview to enable unnamed classes)
Main.java:43: error: class, interface, enum, or record expected
const ll INF = 1e17;
^
Main.java:44: error: class, interface, enum, or record expected
const double pi = acos(-1);
^
Main.java:45: error: class, interface, enum, or record expected
const double EPS = 1e-10;
^
Main.java:46: error: class, interface, enum, or record expected
typedef pair<int, int>P;
^
Main.java:47: error: class, interface, enum, or record expected
const int MAX = 200020;
^
Main.java:51: error: class, interface, enum, or record expected
int N, ga, sa, ba, gb, sb, bb;
^
Main.java:52: error: class, interface, enum, or record expected
int dp[4][5050];
^
Main.java:54: error: illegal start of type
bool cmp(const P& p1, const P& p2) {
         ^
Main.java:59: error: not a statement
	ios::sync_with_stdio(false);
	^
Main.java:61: error: not a statement
	cin >> N >> ga>> sa>> ba>> gb>> sb>> bb;
	                                  ^
Main.java:65: error: not a statement
	p.push_back({ ga,gb });
	              ^
Main.java:65: error: not a statement
	p.push_back({ ga,gb });
	                 ^
Main.java:66: error: not a statement
	p.push_back({ ba,bb });
	              ^
Main.java:66: error: not a statement
	p.push_back({ ba,bb });
	                 ^
Main.java:67: error: not a statement
	p.push_back({ sa,sb });
	              ^
Main.java:67: error: not a statement
	p.push_back({ sa,sb });
	                 ^
Main.java:74: error: not a statement
		int wei[3], val[3];
		               ^
Main.java:95: error: not a statement
		int wei[3], val[3];
		               ^
Main.java:59: error: ';' expected
	ios::sync_with_stdio(false);
	                    ^
Main.java:62: error: ';' expected
	REP(i, 4) {
	         ^
Main.java:63: error: ';' expected
		REP(j, 5050)dp[i][j] = 0;
		            ^
Main.java:65: error: illegal start of expression
	p.push_back({ ga,gb });
	            ^
Main.java:65: error: ';' expected
	p.push_back({ ga,gb });
	                ^
Main.java:65: error: ';' expected
	p.push_back({ ga,gb });
	                   ^
Main.java:65: error: illegal start of expression
	p.push_back({ ga,gb });
	                     ^
Main.java:66: error: illegal start of expression
	p.push_back({ ba,bb });
	            ^
Main.java:66: error: ';' expected
	p.push_back({ ba,bb });
	                ^
Main.java:66: error: ';' expected
	p.push_back({ ba,bb });
	                   ^
Main.java:66: error: illegal start of expression
	p.push_back({ ba,bb });
	                     ^
Main.java:67: error: illegal start of expression
	p.push_back({ sa,sb });
	            ^
Main.java:67: error: ';' expected
	p.push_back({ sa,sb });
	                ^
Main.java:67: error: ';' expected
	p.push_back({ sa,sb });
	                   ^
Main.java:67: error: illegal start of expression
	p.push_back({ sa,sb });
	                     ^
Main.java:69: error: ';' expected
	REP(i, 3) {
	         ^
Main.java:74: error: ']' expected
		int wei[3], val[3];
		        ^
Main.java:75: error: ';' expected
		REP(i, 3) {
		         ^
Main.java:79: error: ';' expected
		REP(i, 3) {
		         ^
Main.java:80: error: ';' expected
			REP(w, N + 1) {
			             ^
Main.java:95: error: ']' expected
		int wei[3], val[3];
		        ^
Main.java:96: error: ';' expected
		REP(i, 3) {
		         ^
Main.java:100: error: ';' expected
		REP(i, 3) {
		         ^
Main.java:101: error: ';' expected
			REP(w, N+1) {
			           ^
Main.java:121: error: ';' expected
		REP(i, N+1) {
		           ^
Main.java:122: error: ';' expected
			REP(j, N+1) {
			           ^
Main.java:132: error: ';' expected
		REP(i, N+1) {
		           ^
Main.java:133: error: ';' expected
			REP(j, N+1) {
			           ^
99 errors