[关闭]
@2368860385 2018-07-02T00:33:59.000000Z 字数 1619 阅读 225

996——Codeforces Round #492 (Div. 2) [Thanks, uDebug!]

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:

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long LL;
  4. inline int read() {
  5. int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
  6. for (;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
  7. }
  8. int a[] = {0,1,5,10,20,100};
  9. int main() {
  10. int n = read(),ans = 0;
  11. ans += n / 100;
  12. n %= 100;
  13. ans += n/20;
  14. n %= 20;
  15. ans += n/10;
  16. n %= 10;
  17. ans += n/5;
  18. n %= 5;
  19. ans += n / 1;
  20. cout << ans;
  21. return 0;
  22. }

B:

  1. By menjiantong, contest: Codeforces Round #492 (Div. 2) [Thanks, uDebug!], problem: (B) World Cup, Accepted, #
  2. #include<bits/stdc++.h>
  3. using namespace std;
  4. typedef long long LL;
  5. inline int read() {
  6. int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
  7. for (;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
  8. }
  9. int main() {
  10. int n = read(),ans,tmp = 1e9;
  11. for (int t,a,b,i=1; i<=n; ++i) {
  12. t = read();
  13. a = t - (i - 1);
  14. if (a <= 0) b = 1;
  15. else b = (a - 1) / n + 2;
  16. if (b < 1) b = 1;
  17. if (b < tmp) tmp = b,ans = i;
  18. }
  19. cout << ans;
  20. return 0;
  21. }

D:

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. typedef long long LL;
  4. inline int read() {
  5. int x=0,f=1;char ch=getchar();for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
  6. for (;isdigit(ch);ch=getchar())x=x*10+ch-'0';return x*f;
  7. }
  8. int a[1010];
  9. int main() {
  10. int n = read(),ans = 0;
  11. for (int i=1; i<=n*2; ++i) a[i] = read();
  12. for (int i=1; i<=n*2; i+=2) {
  13. int p;
  14. for (int j=i+1; j<=n*2; ++j)
  15. if (a[j] == a[i]) {p = j;break;}
  16. for (int j=p; j>=(i+2); --j)
  17. swap(a[j],a[j-1]),ans ++;;
  18. }
  19. cout << ans;
  20. return 0;
  21. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注