Codeforces Round #582 (Div. 3)

Codeforces Round #582 (Div. 3)

A:http://codeforces.com/contest/1213/problem/A
与奇偶性有关,直接判断奇数和偶数的个数谁少 那么就是最少需要的硬币数目

#include <bits/stdc++.h>
const int N=1e5+5;
using namespace std;
int n,m,k;
int a[N];
int main(){
    cin>>n;
    int ans1=0,ans2=0;
    for(int i=1;i<=n;i++)
        scanf("%d",a+i);
    for(int i=1;i<=n;i++)
        ans1+=a[i]%2,ans2+=(a[i]+1)%2;
    printf("%d\n",min(ans1,ans2));
    return 0;
    }

B:http://codeforces.com/contest/1213/problem/B
B题当初看了很久才明白就是如果后面有售价比当前还低,那么就是价格不好的一天。
其实只是需要后面有其中一天比当前的售价低满足就好,然后模拟。(从最后一天开始)

#include <iostream>
using namespace std;

const int N = 1e5+10;
int a[N];
int main()
{
  int k;
  cin>>k;
  while(k--)
  {
    int n;
    cin>>n;
    for(int i = 0;i < n;i++)
      scanf("%d",&a[i]);
    int mind = a[n-1];
    int res = 0;
    for(int i = 0;i < n;i++)
    {
      if(a[i] > mind)
        res++;
      else
        mind = min(mind,a[i]);
    }
    cout<<res<<endl;
  }
  return 0;
}

C:http://codeforces.com/contest/1213/problem/C

当时太菜了,有人提醒我循环节了,可是不懂循环节这就很难搞了

全部评论

相关推荐

码农索隆:这种hr,建议全中国推广
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务