Sereja and Bottles
http://codeforces.com/problemset/problem/315/A
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
struct node
{
int a,b; //a能开b
} q[108];
bool cmp(node x,node y)
{
return x.a<y.a;
}
int w[108]; //标记第i个瓶子是否被开过
int main()
{
int n,i,j,sum;
while(~scanf("%d",&n) && n)
{
sum=0;
for(i=1; i<=n; i++)
{
scanf("%d%d",&q[i].a,&q[i].b);
}
sort(q+1,q+1+n,cmp);
memset(w,0,sizeof(w));
for(i=1; i<=n; i++)
{
for(j=1; j<=n; j++)
{
if(j != i && q[i].b==q[j].a && w[j] == 0)
{
sum++;
w[j]=1;
}
}
}
printf("%d\n",n-sum);
}
return 0;
}
Sereja and Bottles的更多相关文章
- codeforces A. Sereja and Bottles 解题报告
题目链接:http://codeforces.com/problemset/problem/315/A 题目意思:有n个soda bottles,随后给出这n个soda bottles的信息.已知第 ...
- Sereja and Bottles-水题有点坑爹
CodeForces - 315A Sereja and Bottles Time Limit: 2000MS Memory Limit: 262144KB 64bit IO Format: ...
- JSU 2013 Summer Individual Ranking Contest - 5
JSU 2013 Summer Individual Ranking Contest - 5 密码:本套题选题权归JSU所有,需要密码请联系(http://blog.csdn.net/yew1eb). ...
- java线程大全一讲通
Java线程:概念与原理 一.操作系统中线程和进程的概念 现在的操作系统是多任务操作系统.多线程是实现多任务的一种方式. 进程是指一个内存中运行的应用程序,每个进程都有自己独立的一块内存空间,一个进程 ...
- ACM团队周赛题解(1)
这次周赛题目拉了CF315和CF349两套题. 因为我代码模板较长,便只放出关键代码部分 #define ll long long #define MMT(s,a) memset(s, a, size ...
- Codeforces Round #187 (Div. 1 + Div. 2)
A. Sereja and Bottles 模拟. B. Sereja and Array 维护全局增量\(Y\),对于操作1(即\(a_{v_i}=x\))操作,改为\(a_{v_i}=x-Y\). ...
- CF380C. Sereja and Brackets[线段树 区间合并]
C. Sereja and Brackets time limit per test 1 second memory limit per test 256 megabytes input standa ...
- CF 672C Recycling Bottles[最优次优 贪心]
C. Recycling Bottles time limit per test 2 seconds memory limit per test 256 megabytes input standar ...
- Codeforces Round #352 (Div. 2) C. Recycling Bottles 贪心
C. Recycling Bottles It was recycling day in Kekoland. To celebrate it Adil and Bera went to Centr ...
随机推荐
- setCentralWidget就可以把Qwidget设置为QMainWindow的主窗口
前面说的return app.exec() 这句话是用来使程序进入事件循环,除了直接递交的事件外,所有的事件都要在这个循环中被一层一层的分发,最后找到相应的处理函数来处理事件. 顶级窗口和顶级窗口是存 ...
- hdoj 3062 Party(2-SAT)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3062 思路分析:将问题转换为2-SAT问题,需要注意的是将命题转换为有向图的方法:命题中A1, A2, ...
- Objective-c 类的继承 方法重写 方法重载
一.类的继承 Objective-c中类的继承与C++类似,不同的是Objective-c不支持多重继承,一个类只能有一个父类,单继承使Objective-c的继承关系很简单,易于管理程序. Obje ...
- Android API 中文(77)——AdapterView.OnItemSelectedListener
前言 本章内容是android.widget.AdapterView.OnItemSelectedListener,版本为Android 2.3 r1,翻译来自"cnmahj",欢 ...
- PeopleEditor的取值及赋值
/// <summary> /// 从PeopleEditor取值 /// </summary> /// <param name="peopleEditor&q ...
- 网站压力测试工具之WebBench
1 Web Bench简介 WebBench是有名的网站压力测试工具,由Lionbridge公司开发,最多可以模拟3万个并发连接去测试网站的负载能力. Webbech能测试处在相同硬件上,不同服务的性 ...
- CentOS6.5安装MySQL5.7详细教程
注:文中所写的安装过程均在CentOS6.5 x86下通过测试 主要参考博文: https://segmentfault.com/a/1190000003049498 http://www.th7.c ...
- 虚拟环境管理工具virtualenvwrapper-win初试
virtualenv 用于建立虚拟目录,但是每次进入指定虚拟都必须activate, 而且如果一个环境很久没用了,不记得环境所在目录,就会遗忘该环境,virtualenvwrapper 正是解决以上问 ...
- [LeetCode]题解(python):066-Plus One
题目来源: https://leetcode.com/problems/plus-one/ 题意分析: 给定一个数组,将数加一,返回新的数组.比如[9,9],返回[1,0,0]. 题目思路: 这道题目 ...
- 高级UNIX环境编程7 进程
每个程序都会收到一张环境表 extern char **environ; c程序的存储空间布局: 正文段:共享,只读 初始化数据段:存函数以外的赋值 非初始化数据段(bbs):block starte ...