@2368860385
2018-07-02T00:33:59.000000Z
字数 1619
阅读 225
http://codeforces.com/contest/996
codeforces
2018.7.1模拟参加(A,B,D)
2018.7.2整理
A:模拟
B:模拟,判断每个入口到达的时间,并且记录是走完了几次了,找最早的。
D:结论:处于端点的人是不会动的。
做法:端点的人不会动,所以找到他的cp,交换过来
假设左端点的人是L
往右依次为L+1,L+2,L+3....
如果L和L+1配对,那么直接过了
否则,L是不会和L+1交换的,只能L的cp来找L
如果L和L+1换了,那么L,在找他的cp的过程中,减少了一步,但是L+1的cp在找L+1的过程中多了两步,L+1到L,一步,L+1的cp到原来的3号位置为x步,那么到2号位置是x+1
初始:L是1号位置,L+1是2号位置。
A:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
inline int read() {
int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
for (;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}
int a[] = {0,1,5,10,20,100};
int main() {
int n = read(),ans = 0;
ans += n / 100;
n %= 100;
ans += n/20;
n %= 20;
ans += n/10;
n %= 10;
ans += n/5;
n %= 5;
ans += n / 1;
cout << ans;
return 0;
}
B:
By menjiantong, contest: Codeforces Round #492 (Div. 2) [Thanks, uDebug!], problem: (B) World Cup, Accepted, #
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
inline int read() {
int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
for (;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}
int main() {
int n = read(),ans,tmp = 1e9;
for (int t,a,b,i=1; i<=n; ++i) {
t = read();
a = t - (i - 1);
if (a <= 0) b = 1;
else b = (a - 1) / n + 2;
if (b < 1) b = 1;
if (b < tmp) tmp = b,ans = i;
}
cout << ans;
return 0;
}
D:
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
inline int read() {
int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
for (;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
}
int a[1010];
int main() {
int n = read(),ans = 0;
for (int i=1; i<=n*2; ++i) a[i] = read();
for (int i=1; i<=n*2; i+=2) {
int p;
for (int j=i+1; j<=n*2; ++j)
if (a[j] == a[i]) {p = j;break;}
for (int j=p; j>=(i+2); --j)
swap(a[j],a[j-1]),ans ++;;
}
cout << ans;
return 0;
}