usaco——sort3
来源:互联网 发布:linux bashrc 编辑:程序博客网 时间:2024/06/02 16:41
IOI'96 - Day 2
Sorting is one of the most frequently performed computational tasks. Consider the special sorting problem in which the records to be sorted have at most three different key values. This happens for instance when we sort medalists of a competition according to medal value, that is, gold medalists come first, followed by silver, and bronze medalists come last.
In this task the possible key values are the integers 1, 2 and 3. The required sorting order is non-decreasing. However, sorting has to be accomplished by a sequence of exchange operations. An exchange operation, defined by two position numbers p and q, exchanges the elements in positions p and q.
You are given a sequence of key values. Write a program that computes the minimal number of exchange operations that are necessary to make the sequence sorted.
PROGRAM NAME: sort3
INPUT FORMAT
Line 1: N (1 <= N <= 1000), the number of records to be sortedLines 2-N+1: A single integer from the set {1, 2, 3}SAMPLE INPUT (file sort3.in)
9221333231
OUTPUT FORMAT
A single line containing the number of exchanges required
SAMPLE OUTPUT (file sort3.out)
4
这回我用了用库函数,知道了include stdlib.h本来想事用qsort,后来一想没必要。
algorrithm是为了min和max用的,math.h是abs用的(浮点的要用fabs);
stdlib要加h,math也一样,不明白为什么。。。。。。
- usaco——sort3
- USACO sort3
- USACO sort3
- usaco sort3
- 我的 usaco sort3
- usaco 2.1.3 sort3
- usaco 2.1 sort3 2008.5.20
- USACO Sorting A Three-Valued Sequence (sort3)
- USACO-Section2.1 sort3[排序][递归]
- sort3——第一次有模有样的写工程
- USACO 2.1 Sorting A Three-Valued Sequence (sort3)
- usaco——gift1
- usaco——Friday
- usaco——beads
- usaco——milk2
- usaco——transform
- usaco——namenum
- usaco——palsquare
- emacs设置文件关联
- 长尾理论读书笔记:第六章 新市场
- SqlServer 游标例子
- U盘安装系统 (Windows 7篇)(HP) Windows could not update registy data in the installation
- Apache 2.0性能优化—MPM的选择与配置
- usaco——sort3
- 奈何浮生不若梦
- 最近演讲中引用的一个故事,但主人公说错了,特此更正!
- 重新开始,做一个程序员
- JavaScript 解析读取XML文档
- 百度能否抢占移动搜索市场话语权?
- 在Delphi中,字符串查找 函数
- SWT之GridLayout使用详解
- 看看日本人对汉字的研究