#include <stdio.h>
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx,avx2,bmi,bmi2,popcnt,lzcnt")
#define ll long long
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__);
void max_self(int& a, int b) {
a = max(a, b);
}
int init(int n, int x[], int y[]) {
const int nax = 1003;
vector<int> dp(nax), new_dp(nax);
vector<int> vis(nax), new_vis(nax);
vis[1] = 1;
dp[1] = 0; // max score so far
for(int i = 0; i < n; ++i) {
// dbg(x[i], y[i])
// either sell some number of horses and multiply the rest
for(int h = 0; h < nax; ++h) {
if(!vis[h]) continue;
int disp = h * x[i];
for(int sell = 0; sell <= disp; ++sell) {
// cerr << (h - sell) * x[i] << "\n";
max_self(new_dp[(disp - sell) * x[i]], dp[h] + sell * y[i]);
new_vis[(disp - sell) * x[i]] = 1;
}
}
swap(dp, new_dp);
swap(vis, new_vis);
}
int ans = 0;
for(int i = 0; i < nax; ++i) {
max_self(ans, dp[i]);
}
return ans;
}
int updateX(int pos, int val) {
return 0;
}
int updateY(int pos, int val) {
return 0;
}
// static char buffer[1024];
// static int currentChar = 0;
// static int charsNumber = 0;
// static inline int read() {
// if (charsNumber < 0) {
// exit(1);
// }
// if (!charsNumber || currentChar == charsNumber) {
// charsNumber = (int)fread(buffer, sizeof(buffer[0]), sizeof(buffer), stdin);
// currentChar = 0;
// }
// if (charsNumber <= 0) {
// return -1;
// }
// return buffer[currentChar++];
// }
// static inline int readInt() {
// int x; cin >> x;
// return x;
// }
// int main() {
// int N;
// N = readInt();
// int *X = (int *)malloc(sizeof(int) * (unsigned int)N);
// int *Y = (int *)malloc(sizeof(int) * (unsigned int)N);
// for (int i = 0; i < N; i++) {
// X[i] = readInt();
// }
// for (int i = 0; i < N; i++) {
// Y[i] = readInt();
// }
// printf("%d\n", init(N, X, Y));
// int M;
// M = readInt();
// for (int i = 0; i < M; i++) {
// int type;
// type = readInt();
// int pos;
// pos = readInt();
// int val;
// val = readInt();
// if (type == 1) {
// printf("%d\n", updateX(pos, val));
// } else if (type == 2) {
// printf("%d\n", updateY(pos, val));
// }
// }
// return 0;
// }
Compilation message
horses.cpp: In function 'int updateX(int, int)':
horses.cpp:53:17: warning: unused parameter 'pos' [-Wunused-parameter]
53 | int updateX(int pos, int val) {
| ~~~~^~~
horses.cpp:53:26: warning: unused parameter 'val' [-Wunused-parameter]
53 | int updateX(int pos, int val) {
| ~~~~^~~
horses.cpp: In function 'int updateY(int, int)':
horses.cpp:56:17: warning: unused parameter 'pos' [-Wunused-parameter]
56 | int updateY(int pos, int val) {
| ~~~~^~~
horses.cpp:56:26: warning: unused parameter 'val' [-Wunused-parameter]
56 | int updateY(int pos, int val) {
| ~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1586 ms |
4164 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |