美文网首页
CodeFoeces-992A

CodeFoeces-992A

作者: ss5smi | 来源:发表于2018-07-13 19:16 被阅读0次

题目

原题链接:A. Nastya and an Array

题意

由n个数字组成的序列,每次可以给任意数字增加或减少任意数值,问多少次操作才能使所有数字为0.

代码

#include<bits/stdc++.h>
using namespace std;
int main() {
    int n,s[100000];
    set<int> tmp;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>s[i];
        if(s[i]!=0) tmp.insert(s[i]);
    }
    printf("%d\n",tmp.size());
    return 0;
}

相关文章

  • CodeFoeces-992A

    题目 原题链接:A. Nastya and an Array 题意 由n个数字组成的序列,每次可以给任意数字增加或...

网友评论

      本文标题:CodeFoeces-992A

      本文链接:https://www.haomeiwen.com/subject/bycreftx.html