#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define all(v) v.begin(), v.end()
#define dbg(v) "[" #v " = " << (v) << "]"
template<typename T> bool maximize(T &a, T b) {
if(a < b) {
a = b;
return true;
}else return false;
}
template<typename T> bool minimize(T &a, T b) {
if(a > b) {
a = b;
return true;
}else return false;
}
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
const int N = 1e5 + 3;
int n;
double a[N], b[N];
namespace subtask1 {
double best = 0;
void backtrack(int p, double totalA, double totalB, int counter) {
if(p > n) {
maximize(best, min(totalA - (double)counter, totalB - (double)counter));
return;
}
backtrack(p + 1, totalA, totalB, counter);
backtrack(p + 1, totalA + a[p], totalB, counter + 1);
backtrack(p + 1, totalA, totalB + b[p], counter + 1);
backtrack(p + 1, totalA + a[p], totalB + b[p], counter + 2);
}
void solve() {
backtrack(1, 0, 0, 0);
cout << fixed << setprecision(4) << best << endl;
}
};
namespace subtask2 {
double dpOne[N][5];
void solve() {
}
}
void process() {
if(n <= 10) {
subtask1::solve();
return;
}
assert(1 == 0);
}
void input() {
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> a[i] >> b[i];
}
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
#define task "DateALive"
if(fopen(task".INP", "r")) {
freopen(task".INP", "r", stdin);
freopen(task".OUT", "w", stdout);
}
input();
process();
return 0;
}
Compilation message
sure.cpp: In function 'int main()':
sure.cpp:81:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
81 | freopen(task".INP", "r", stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:82:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
82 | freopen(task".OUT", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
4 ms |
336 KB |
Output is correct |
4 |
Correct |
7 ms |
336 KB |
Output is correct |
5 |
Correct |
4 ms |
504 KB |
Output is correct |
6 |
Correct |
4 ms |
504 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
4 ms |
336 KB |
Output is correct |
4 |
Correct |
7 ms |
336 KB |
Output is correct |
5 |
Correct |
4 ms |
504 KB |
Output is correct |
6 |
Correct |
4 ms |
504 KB |
Output is correct |
7 |
Runtime error |
2 ms |
592 KB |
Execution killed with signal 6 |
8 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
4 ms |
336 KB |
Output is correct |
4 |
Correct |
7 ms |
336 KB |
Output is correct |
5 |
Correct |
4 ms |
504 KB |
Output is correct |
6 |
Correct |
4 ms |
504 KB |
Output is correct |
7 |
Runtime error |
2 ms |
592 KB |
Execution killed with signal 6 |
8 |
Halted |
0 ms |
0 KB |
- |