【CSP试题回顾】202109-1-数组推导

CSP-202109-1-数组推导

解题代码

cpp 复制代码
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

long long maxSum, minSum;

int main() {   
    int n;
    cin >> n;

    vector<int>B(n);
    for (auto& it : B)
    {
        cin >> it;
        maxSum += it;
    }

    auto last = unique(B.begin(), B.end());
    B.erase(last, B.end());
    for (auto& it : B) {
        minSum += it;
    }

    cout << maxSum << endl << minSum;
    return 0;
}
相关推荐
小灰灰爱代码2 小时前
C++——求3*3矩阵对角元素之和。
数据结构·c++·算法
老K(郭云开)2 小时前
allWebPlugin中间件自定义alert、confirm及prompt使用
c++·chrome·中间件·prompt·html5·edge浏览器
福鸦4 小时前
详解c++:new和delete
开发语言·c++
createcrystal5 小时前
《算法笔记》例题解析 第3章入门模拟--3图形输出(9题)2021-03-03
c++·笔记·算法
我要学编程(ಥ_ಥ)5 小时前
双指针算法专题(2)
数据结构·算法·leetcode
逸狼5 小时前
【JavaEE初阶】多线程6(线程池\定时器)
java·开发语言·算法
no_play_no_games6 小时前
[模板]树的最长路径
算法·深度优先·图论·树形结构
tan77º6 小时前
【C++】异常
c++·算法
ymchuangke6 小时前
数据清洗-缺失值处理-缺失值可视化图(竖线)
python·算法·数学建模
我要学编程(ಥ_ಥ)7 小时前
滑动窗口算法专题(1)
java·数据结构·算法·leetcode