博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
No Girlfriend(简单题)
阅读量:4037 次
发布时间:2019-05-24

本文共 1333 字,大约阅读时间需要 4 分钟。

1、

2、题目大意

情人节将至,有n个人分别跟自己喜欢的人约会,给出每个人约会的人编号,如果带走其中一个人,那么喜欢这个人的那些人将会不开心,现在你要带走一个人,使得不开心的人数最多

简单题,不过太心急了,没有注意好边界就提交,导致wrong了两遍才AC

3、题目:

  • [C] No Girlfriend

  • 时间限制: 2000 ms 内存限制: 262144 K       
  • 问题描述
  • You know the day after tomorrow is Valentine's Day, but I have no girlfriend.

    Now, I'll give you a big task, help me take away a person!

    If you take away that person, others who want to appointment with him/her will feel disappointed.

    Your task is to let maximum people feel disappointed.

  • 输入
  • There are multiple test cases, each test case contain a positive number N (1 <= N <= 100).
    Following N lines, for the ith line (1-Based) contain a positive integer P (1 <= P <= N), represent the ith people want to appointment with P.
    Note: Everyone has a distinct number, the ith people's number is i.
  • 输出
  • For each case, output the answer in one line.           
  • 样例输入
  • 3311555222
  • 样例输出
  • 23
  • 提示
  • For the first test case.If you take away 1, then 2 and 3 will feel disappointed.If you take away 2, nobody will feel disappointed.If you take away 3, then 1 will feel disappointed.So the maximum people feel disappointed is 2.

     

    4、AC代码:

    #include
    #include
    #include
    using namespace std;int b[105];int cmp(int c,int d){ return c>d;}int main(){ int n,a; while(scanf("%d",&n)!=EOF) { memset(b,0,sizeof(b)); for(int i=0;i

     

转载地址:http://ngddi.baihongyu.com/

你可能感兴趣的文章
yuv420 还原为RGB图像
查看>>
LED恒流驱动芯片
查看>>
驱动TFT要SDRAM做为显示缓存
查看>>
使用file查看可执行文件的平台性,x86 or arm ?
查看>>
qt5 everywhere 编译summary
查看>>
qt5 everywhere编译完成后,找不到qmake
查看>>
arm-linux开机读取硬件时钟,设置系统时钟。
查看>>
交叉编译在x86上调试好的qt程序
查看>>
/dev/input/event0 键盘输入
查看>>
qt 创建异形窗体
查看>>
可重入函数与不可重入函数
查看>>
简单Linux C线程池
查看>>
内存池
查看>>
输入设备节点自动生成
查看>>
opencv test code-1
查看>>
eclipse 导入先前存在的项目
查看>>
GNU hello代码分析
查看>>
Qt继电器控制板代码
查看>>
busybox passwd修改密码
查看>>
wpa_supplicant控制脚本
查看>>