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 ...
随机推荐
- 关于Qt信号与槽机制的传递方向性研究(结论其实是错误的,但是可以看看分析过程)
最近由于项目的需求,一直在研究Qt.信号与槽机制是Qt的一大特色,该机制允许两者间传递参数,依次来实现对象间的通信.这个参数会分别存在于信号的参数列表和槽函数的参数列表中.需要注意的是,若将槽函数绑定 ...
- HDU 1234 开门人和关门人
#include <string> #include <algorithm> #include <iostream> using namespace std; st ...
- POJ-1006 Biorhythms
[题目描述] 三个周期时间分别为:23,28和33.分别给定三个周期的某一天(不一定是第一天),和开始计算的日期,输出下一个triple peak. [思路分析] 如果不了解中国剩余定理,可以通过模拟 ...
- android 中文 api (72) —— BluetoothSocket[蓝牙]
前言 本章内容是 android.bluetooth.BluetoothSocket,为Android蓝牙部分的章节翻译.蓝牙通讯套接字,代表了与远端设备的连接点,使用socket本地程序可以通过 ...
- HTML之表格与表单
一.表格(table/tr/td) <table></table>表格 --不设高度 width:宽度.可以用像素或百分比表示. 常用960像素. border:边框,常用值为 ...
- iOS开发之第三方分享QQ分享,史上最新最全第三方分享QQ方式实现
本文章源码地址: https://github.com/zhonggaorong/QQLoginDemo 项目搭建参考: (包含QQ登录源码下载 . QQ sdk集成) http://blog.cs ...
- Java基础之编程语法(二)
1.常量: 整型:整数,4个字节. 长整型:整数,8个字节.以L结尾. 单精度浮点数:小数,4个字节.以F结尾. 双精度浮点数:小数,8个字节. 布尔:只有两个值,真(true)或假(false),1 ...
- FtpManager类
public class FtpManager { /// <summary> /// 主机名 /// </summary> string ftpServerIP; /// & ...
- Resource is out of sync with the file system: 解决办法
在eclipse中,启动server时报此错,是因为文件系统不同步造成的,解决方法有两个: (1)选中工程,右键,选择F5(手动刷新): (2)Window->Preferences->G ...
- [LeetCode]题解(python):026-Remove Duplicates from Sorted Array
题目来源: https://leetcode.com/problems/remove-duplicates-from-sorted-array/ 题意分析: 给定一个排好序的数组,去除重复的数,返回新 ...