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 ...
随机推荐
- NHibernate 的 ID 标识选择器
在 Hibernate 中,每个对象需要一个标识 ID,通过这个标识 ID 建立对象与数据库中记录的对应关系. Nhibernate 提供了多种方式来建立这个 POID.基于不同的生成策略,可以选择更 ...
- HDU 1398 Square Coins
题目大意:有面值分别为.1,4,9,.......17^2的硬币无数多个.问你组成面值为n的钱的方法数. 最简单的母函数模板题: #include <cstdio> #include &l ...
- HDU题解索引
HDU 1000 A + B Problem I/O HDU 1001 Sum Problem 数学 HDU 1002 A + B Problem II 高精度加法 HDU 1003 Maxsu ...
- 什么是Thrift
起源 百度百科怎么说 thrift是一个软件框架,用来进行可扩展且跨语言的服务的开发. 它结合了功能强大的软件堆栈和代码生成引擎,以构建在 C++, Java, Python, PHP, Ruby, ...
- 【cocos2d-x】Win7下配置Cocos2d-x开发环境
一.下载安装包 先去Cocos2d-x官网下载安装包,最新版本为cocos2d-2.1.5 http://www.cocos2d-x.org/news/134 二.解压安装包 下载完成后,解压文件,解 ...
- Ext JS学习第十天 Ext基础之 扩展原生的javascript对象(二)
此文来记录学习笔记: 今天继续说Ext.Array,Ext.Function,Ext.Date,Ext.Error ------------------------------------------ ...
- document.execCommand()函数可用参数解析
隐藏在暗处的方法-execCommand() 关键字: javascript document document.execCommand()方法可用来执行很多我们无法实现的操作. execComman ...
- 常用类库StringBuilder
1.使用StringBuilder拼接字符串实例: string[] lines = File.ReadAllLines("sdjk.txt", Encoding.Default) ...
- C++创建对象的三种方式
C++在创建对象的时候,有三种方式: #include <iostream> using namespace std; class A { private: int n; public: ...
- Shell Script(1)----variable compare
PS:在学习python的时间里,抽空复习自己学习的Linux下的shell脚本知识点 1.数据类型 学习一门语言,比较关心其数据的表示方式,以及数据的类型,这里首先看一个bash shell的脚本 ...