World Robot Contest2025-2026Algorithm Application ThemeJunior Highwrc.hao.work
WRC
Contest Archive / Structured Dossiers青少年算法应用训练档案馆

把训练题、知识点、执行证据和最终解题档案统一归档成可直接浏览的竞赛资料库。

Archive30 Cases

四大文化赛道完整展开

AccessHTTPS

完整题面 / 题解 / 运行证据

No Rounded CornersTailwind FirstDossier Ready
03-execution/run-002/source-snapshot/main.cpp

main.cpp

站内文件视图直接读取仓库内容,Markdown 使用文档排版渲染,其余文本文件保持原始排版,方便校对训练证据链。

文件类型.cpp

10-cases/s2-jh-02-livelihood-trend/03-execution/run-002/source-snapshot/main.cpp

#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> values(n);
    for (int i = 0; i < n; ++i) {
        cin >> values[i];
    }
    long long total_change = values.back() - values.front();
    int longest = 1;
    int current = 1;
    for (int i = 1; i < n; ++i) {
        if (values[i] > values[i - 1]) {
            ++current;
        } else {
            current = 1;
        }
        if (current > longest) {
            longest = current;
        }
    }
    int recent_count = min(3, n);
    long long recent_sum = 0;
    for (int i = n - recent_count; i < n; ++i) {
        recent_sum += values[i];
    }
    long long forecast = round_half_up(recent_sum, recent_count);
    cout << "total_change=" << total_change << "\n";
    cout << "longest_rise=" << longest << "\n";
    cout << "forecast=" << forecast << "\n";
    return 0;
}