四大文化赛道完整展开
03-execution/run-002/source-snapshot/main.cpp
main.cpp
站内文件视图直接读取仓库内容,Markdown 使用文档排版渲染,其余文本文件保持原始排版,方便校对训练证据链。
文件类型.cpp
10-cases/s4-jh-03-promotion-forecast/03-execution/run-002/source-snapshot/main.cpp
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
long long round_half_up(long long total, long long count) {
return (2 * total + count) / (2 * count);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
if (!(cin >> n)) {
return 0;
}
vector<long long> visits;
long long total_visits = 0;
long long total_orders = 0;
int best_day = 1;
long long best_orders = -1;
for (int day = 1; day <= n; ++day) {
long long v, o;
cin >> v >> o;
visits.push_back(v);
total_visits += v;
total_orders += o;
if (o > best_orders) {
best_orders = o;
best_day = day;
}
}
int recent_count = min(3, n);
long long recent_sum = 0;
for (int i = n - recent_count; i < n; ++i) {
recent_sum += visits[i];
}
long long forecast_visits = round_half_up(recent_sum, recent_count);
long long forecast_orders = round_half_up(forecast_visits * total_orders, total_visits);
double conversion = total_orders * 100.0 / total_visits;
cout << fixed << setprecision(2);
cout << "conversion=" << conversion << "\n";
cout.unsetf(ios::floatfield);
cout << "forecast=" << forecast_visits << ' ' << forecast_orders << "\n";
cout << "best_day=" << best_day << "\n";
return 0;
}