Skip to main content
  1. Posts/

codeforces 612 B. HDD is Outdated Technology

·1 min
Note: This article is available in Chinese only. 本文暂无英文版本。 View original

http://codeforces.com/contest/612/problem/B 水。

 1/* ***********************************************
 2Author :111qqz
 3Created Time :2015年12月25日 星期五 22时58分38秒
 4File Name :code/cf/edu4/B.cpp
 5************************************************ */
 6
 7#include <cstdio>
 8#include <cstring>
 9#include <iostream>
10#include <algorithm>
11#include <vector>
12#include <queue>
13#include <set>
14#include <map>
15#include <string>
16#include <cmath>
17#include <cstdlib>
18#include <ctime>
19#define fst first
20#define sec second
21#define lson l,m,rt<<1
22#define rson m+1,r,rt<<1|1
23#define ms(a,x) memset(a,x,sizeof(a))
24typedef long long LL;
25#define pi pair < int ,int >
26#define MP make_pair
27
28using namespace std;
29const double eps = 1E-8;
30const int dx4[4]={1,0,0,-1};
31const int dy4[4]={0,-1,1,0};
32const int inf = 0x3f3f3f3f;
33const int N=2E5+7;
34int n;
35struct node
36{
37    int val;
38    int id;
39
40    bool operator <(node b)const
41    {
42	return val<b.val;
43    }
44}q[N];
45int main()
46{
47	#ifndef  ONLINE_JUDGE
48	freopen("code/in.txt","r",stdin);
49  #endif
50	cin>>n;
51	for ( int i = 1 ;  i <= n ; i++ )
52	{
53	    scanf("%d",&q[i].val);
54	    q[i].id = i;
55	}
56	sort(q+1,q+n+1);
57	LL ans = 0 ;
58	q[0].id = 0 ;
59	for ( int i = 1 ; i <= n-1 ; i++)
60	{
61	    ans += LL (abs(q[i+1].id-q[i].id));
62	}
63	cout<<ans<<endl;
64
65  #ifndef ONLINE_JUDGE
66  fclose(stdin);
67  #endif
68    return 0;
69}

Related

codeforces 612 A. The Text Splitting

http://codeforces.com/contest/612/problem/A 水题…直接枚举就好。 1/* *********************************************** 2Author :111qqz 3Created Time :2015年12月25日 星期五 22时58分26秒 4File Name :code/cf/edu4/A.cpp 5************************************************ */ 6 7#include <cstdio> 8#include <cstring> 9#include <iostream> 10#include <algorithm> 11#include <vector> 12#include <queue> 13#include <set> 14#include <map> 15#include <string> 16#include <cmath> 17#include <cstdlib> 18#include <ctime> 19#define fst first 20#define sec second 21#define lson l,m,rt<<1 22#define rson m+1,r,rt<<1|1 23#define ms(a,x) memset(a,x,sizeof(a)) 24typedef long long LL; 25#define pi pair < int ,int > 26#define MP make_pair 27 28using namespace std; 29const double eps = 1E-8; 30const int dx4[4]={1,0,0,-1}; 31const int dy4[4]={0,-1,1,0}; 32const int inf = 0x3f3f3f3f; 33const int N=105; 34int n,p,q; 35char st[N]; 36bool v[10005]; 37int main() 38{ 39 #ifndef ONLINE_JUDGE 40 freopen("code/in.txt","r",stdin); 41 #endif 42 cin>>n>>p>>q; 43 cin>>st; 44 ms(v,false); 45 int b,c; 46 for ( int i = 0 ; i*p<=105 ; i++ ) 47 { 48 for ( int j = 0 ; j*q <= 105 ; j++) 49 { 50 v[i*p+j*q] = true; 51 if (i*p+j*q==n) 52 { 53 b = i; 54 c = j; 55 } 56 } 57 } 58// cout<<"b:"<<b<<endl; 59// cout<<"c:"<<c<<endl; 60 if (!v[n]) 61 { 62 puts("-1"); 63 } 64 else 65 { 66 int cnt = 0 ; 67 printf("%d\n",b+c); 68 for ( int i = 1 ; i <= b ; i++) 69 { 70 for ( int i = 0 ; i < p ; i++) 71 printf("%c",st[cnt]),cnt++; 72 printf("\n"); 73 } 74 for ( int i =1 ; i <= c ; i++) 75 { 76 for ( int i = 0 ; i < q ; i++) 77 printf("%c",st[cnt]),cnt++; 78 printf("\n"); 79 } 80 } 81 82 83 84 #ifndef ONLINE_JUDGE 85 fclose(stdin); 86 #endif 87 return 0; 88}

uva 6692 Lucky Number

·1 min
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid;=8&page;=show_problem&problem;=4704 题目大意是说,定义一个数的lucky number是距离i最远的j且满足(a[i]<a[j] i<j)。

poj 2159 Ancient Cipher(水)

·1 min
由于顺序是可以改变的. 所以考虑是否可以映射.只要存在字母对应出现的次数都相同.那么就可以通过映射得到. 具体是开一个数组记录每个字母出现的次数… 然后sort

codeforces #317 div2 A. Arrays (水)

·1 min
应该3分钟过的题。。。 结果花了8分钟。。。ssssad 1/************************************************************************* 2 > File Name: code/cf/#317/A.cpp 3 > Author: 111qqz 4 > Email: rkz2013@126.com 5 > Created Time: 2015年08月23日 星期日 00时29分47秒 6 ************************************************************************/ 7 8#include<iostream> 9#include<iomanip> 10#include<cstdio> 11#include<algorithm> 12#include<cmath> 13#include<cstring> 14#include<string> 15#include<map> 16#include<set> 17#include<queue> 18#include<vector> 19#include<stack> 20#include<cctype> 21#define y1 hust111qqz 22#define yn hez111qqz 23#define j1 cute111qqz 24#define ms(a,x) memset(a,x,sizeof(a)) 25#define lr dying111qqz 26using namespace std; 27#define For(i, n) for (int i=0;i<int(n);++i) 28typedef long long LL; 29typedef double DB; 30const int inf = 0x3f3f3f3f; 31const int N=1E5+7; 32int na,nb,k,m; 33int a[N],b[N]; 34int main() 35{ 36 #ifndef ONLINE_JUDGE 37 freopen("in.txt","r",stdin); 38 #endif 39 cin>>na>>nb; 40 cin>>k>>m; 41 for ( int i = 1 ; i <= na ; i++){ 42 scanf("%d",&a[i]); 43 } 44 for ( int i = 1 ; i<= nb ; i++){ 45 scanf("%d",&b[i]); 46 } 47 if (a[k]<b[nb-m+1]){ 48 puts("YES"); 49 } 50 else 51 { 52 puts("NO"); 53 } 54 55 56 #ifndef ONLINE_JUDGE 57 fclose(stdin); 58 #endif 59 return 0; 60}

codeforces 612 D. The Union of k-Segments

·2 mins
http://codeforces.com/contest/612/problem/D 题意:给出n个线段信息,每个线段以l,r的形式给出。给定k。要求从作到右给出至少有k个线段覆盖的区间的信息。并使得区间数目尽可能少。