이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
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);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |