Submission #488129

#TimeUsernameProblemLanguageResultExecution timeMemory
488129TruaShamuCloud Computing (CEOI18_clo)Java
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; #define pb push_back #define all(x) begin(x), end(x) #define sz(x) (int) (x).size() using pi = pair<int, int>; #define f first #define s second #define mp make_pair void setIO(string name = "") { cin.tie(0)->sync_with_stdio(0); // see /general/fast-io if (sz(name)) { freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output freopen((name + ".out").c_str(), "w", stdout); } } struct event { int cores; int rate; int price; bool operator < (const event& b) const { return rate != b.rate ? rate > b.rate : price < b.price; } }; int main() { setIO(); vector<event> events; int N; cin >> N; // Computer int maxComp = 0; for (int i = 0; i < N; i++) { event oEvent; cin >> oEvent.cores >> oEvent.rate >> oEvent.price; oEvent.price *= -1; events.pb(oEvent); maxComp += oEvent.cores; } // Order int M; cin >> M; for (int i = 0; i < M; i++) { event oEvent; cin >> oEvent.cores >> oEvent.rate >> oEvent.price; oEvent.cores *= -1; events.pb(oEvent); } // Print std::sort(events.begin(), events.end()); vector<ll> dp(maxComp + 1, INT64_MIN); dp[0] = 0; for (const event& oEvent : events) { vector<ll> newMax(dp); for (int c = 0; c <= maxComp; c++) { int prevComp = c - oEvent.cores; if (prevComp >= 0 && prevComp <= maxComp && dp[prevComp] != INT64_MIN) { newMax[c] = max(newMax[c], dp[prevComp] + oEvent.price); } } dp = newMax; } cout << *max_element(dp.begin(), dp.end()); }

Compilation message (stderr)

clo.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
clo.java:1: error: class, interface, or enum expected
#include <bits/stdc++.h>
         ^
clo.java:4: error: class, interface, or enum expected
using ll = long long;
^
clo.java:6: error: class, interface, or enum expected
using vi = vector<int>;
^
clo.java:7: error: illegal character: '#'
#define pb push_back
^
clo.java:7: error: class, interface, or enum expected
#define pb push_back
        ^
clo.java:8: error: illegal character: '#'
#define all(x) begin(x), end(x)
^
clo.java:9: error: illegal character: '#'
#define sz(x) (int) (x).size()
^
clo.java:12: error: illegal character: '#'
#define f first
^
clo.java:12: error: class, interface, or enum expected
#define f first
        ^
clo.java:13: error: illegal character: '#'
#define s second
^
clo.java:14: error: illegal character: '#'
#define mp make_pair
^
clo.java:18: error: class, interface, or enum expected
	if (sz(name)) {
	^
clo.java:20: error: class, interface, or enum expected
		freopen((name + ".out").c_str(), "w", stdout);
		^
clo.java:21: error: class, interface, or enum expected
	}
	^
clo.java:28: error: class, interface, or enum expected
	int rate;
	^
clo.java:29: error: class, interface, or enum expected
	int price;
	^
clo.java:30: error: class, interface, or enum expected
	bool operator < (const event& b) const {
	^
clo.java:32: error: class, interface, or enum expected
	}
	^
clo.java:35: error: class, interface, or enum expected
int main() {
^
clo.java:37: error: class, interface, or enum expected
	vector<event> events;
	^
clo.java:38: error: class, interface, or enum expected
	int N; cin >> N;
	^
clo.java:38: error: class, interface, or enum expected
	int N; cin >> N;
	       ^
clo.java:40: error: class, interface, or enum expected
	int maxComp = 0;
	^
clo.java:41: error: class, interface, or enum expected
	for (int i = 0; i < N; i++) {
	^
clo.java:41: error: class, interface, or enum expected
	for (int i = 0; i < N; i++) {
	                ^
clo.java:41: error: class, interface, or enum expected
	for (int i = 0; i < N; i++) {
	                       ^
clo.java:43: error: class, interface, or enum expected
		cin >> oEvent.cores >> oEvent.rate >> oEvent.price;
		^
clo.java:44: error: class, interface, or enum expected
		oEvent.price *= -1;
		^
clo.java:45: error: class, interface, or enum expected
		events.pb(oEvent);
		^
clo.java:46: error: class, interface, or enum expected
		maxComp += oEvent.cores;
		^
clo.java:47: error: class, interface, or enum expected
	}
	^
clo.java:50: error: class, interface, or enum expected
	int M; cin >> M;
	       ^
clo.java:51: error: class, interface, or enum expected
	for (int i = 0; i < M; i++) {
	^
clo.java:51: error: class, interface, or enum expected
	for (int i = 0; i < M; i++) {
	                ^
clo.java:51: error: class, interface, or enum expected
	for (int i = 0; i < M; i++) {
	                       ^
clo.java:53: error: class, interface, or enum expected
		cin >> oEvent.cores >> oEvent.rate >> oEvent.price;
		^
clo.java:54: error: class, interface, or enum expected
		oEvent.cores *= -1;
		^
clo.java:55: error: class, interface, or enum expected
		events.pb(oEvent);
		^
clo.java:56: error: class, interface, or enum expected
	}
	^
clo.java:60: error: class, interface, or enum expected
	vector<ll> dp(maxComp + 1, INT64_MIN);
	^
clo.java:61: error: class, interface, or enum expected
	dp[0] = 0;
	^
clo.java:62: error: class, interface, or enum expected
	for (const event& oEvent : events) {
	^
clo.java:64: error: class, interface, or enum expected
		for (int c = 0; c <= maxComp; c++) {
		^
clo.java:64: error: class, interface, or enum expected
		for (int c = 0; c <= maxComp; c++) {
		                ^
clo.java:64: error: class, interface, or enum expected
		for (int c = 0; c <= maxComp; c++) {
		                              ^
clo.java:66: error: class, interface, or enum expected
			if (prevComp >= 0 && prevComp <= maxComp && dp[prevComp] != INT64_MIN) {
			^
clo.java:68: error: class, interface, or enum expected
			}
			^
clo.java:71: error: class, interface, or enum expected
	}
	^
clo.java:73: error: class, interface, or enum expected
}
^
50 errors