CPC23四 A.
来源:互联网 发布:池州安广网络安装人员 编辑:程序博客网 时间:2024/05/23 12:00
A.Running Around Park
Time Limit: 10000 MS Memory Limit: 65536 K
Total Submit: 72 (52 users) Total Accepted: 53 (52 users) Special Judge: No
DescriptionTime Limit: 10000 MS Memory Limit: 65536 K
Total Submit: 72 (52 users) Total Accepted: 53 (52 users) Special Judge: No
Alice went jogging around the park yesterday. There is a circular track around the park, and Alice's house is right next to the track. Alice ran in the clockwise direction. She both started and ended her run at her house. In other words, she completed some positive number of full laps.
There are N trees along the track. The trees are numbered 1 through N in the order in which Alice encounters them when running a single lap. You are given the int N.
Alice remembers some trees she saw during her run. She remembers them in the order in which she encountered them. You are given this information as a int[] d.
For example, d={6,6,1} has the following meaning:
Alice started running.
After some time she encountered the tree number 6.
After some more time she encountered the tree number 6.
Even later she encountered the tree number 1.
Compute and return the smallest possible number of laps Alice completed.
Input
For each test data. The first line contains two number N and dN.
The second line contains dN number, the ith of them is di.
- N will be between 2 and 50, inclusive.
- dN will between 1 and 50.
- Each element of d will be between 1 and N, inclusive.
Output
For each test, compute and return the smallest possible number of laps Alice completed.
Sample Input
3 3
1 2 3
24 2
6 6
3 3
3 2 1
50 10
1 3 5 7 9 2 4 6 8 10
Sample Output
1
2
3
2
解题思路:
题意是一个人绕着田径场跑圈,树从1~n标号,给出沿途遇见的树的标号,问这个人最后总共跑了多少圈。
如果当前树的标号小于等于前一个树的标号,那么圈数加1.
完整代码:
#include <functional>#include <algorithm>#include <iostream>#include <fstream>#include <sstream>#include <iomanip>#include <numeric>#include <cstring>#include <climits>#include <cassert>#include <complex>#include <cstdio>#include <string>#include <vector>#include <bitset>#include <queue>#include <stack>#include <cmath>#include <ctime>#include <list>#include <set>#include <map>using namespace std;#pragma comment(linker, "/STACK:102400000,102400000")typedef long long LL;typedef double DB;typedef unsigned uint;typedef unsigned long long uLL;/** Constant List .. **/ //{const int MOD = int(1e9)+7;const int INF = 0x3f3f3f3f;const LL INFF = 0x3f3f3f3f3f3f3f3fLL;const DB EPS = 1e-9;const DB OO = 1e20;const DB PI = acos(-1.0); //M_PI;int a[100001];int main(){ #ifdef DoubleQ freopen("in.txt","r",stdin); #endif int n , m; while(~scanf("%d%d",&n,&m)) { for(int i = 0 ;i < m ; i++) { scanf("%d",&a[i]); } int cnt = 1; for(int i = 1 ; i < m ; i ++) { if(a[i] <= a[i-1]) cnt++; } printf("%d\n",cnt); }}
0 0
- CPC23四 A.
- CPC23第三场、第四场总结
- CPC23三 K.(Lucas定理)
- <css 四>a href
- 专题四 Problem A
- 专题四 Problem A
- 哈尔滨理工大学-CPC23 2014-2-D-Alice and Bob
- CPC23 2014-1 B.Crossings(求逆序数)
- CPC23-4 K.喵喵的神·数
- a++, a+=1,a=a+1,++a 四者的区别
- 哈尔滨理工大学-CPC23 2014-3-K-喵喵的神·数
- CPC23-4-K. 喵喵的神数 (数论 Lucas定理)
- A Practical Tutorial Of Zend Framework(四)
- 通过四种方法查找字符A
- A 项目 实战 (四) ClassPathXmlApplicationContext
- CSS a链接的四种状态
- <a>标签的四种链接状态
- A*寻路算法入门(四)
- Git(三):添加与提交
- 一张图让你明白SQL各种连接
- 风中追风,HTML
- sqoop
- HDU 4790 Just Random (2013ACM/ICPC成都赛区现场赛J题)
- CPC23四 A.
- [field:description /]文章摘要字数的设置方法
- 常用的排序算法之冒泡排序java版
- 学生信息管理系统
- GetDc与GetWindowDc的含义
- 状态压缩递推(States Compressing Recursion,SCR)
- 字符串函数---strcpy()与strncpy()详解及实现
- LeetCode: Unique Binary Search Trees
- HDU1074