AtCoder Beginner Contest 072
生活随笔
收集整理的這篇文章主要介紹了
AtCoder Beginner Contest 072
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
這應(yīng)該是我第二次打AtCoder, 題目其實(shí)并不難,就是自己經(jīng)驗(yàn)不足想復(fù)雜了,再加上自己很笨,愣是做了97分鐘才全做出來(lái)(最后三分鐘,有點(diǎn)小激動(dòng)。。),看著前面大牛半個(gè)小時(shí)都搞完了,真心膜拜一下,代碼其實(shí)沒什么可看的,題目也沒什么可說(shuō)的,就是為了貼出來(lái)總結(jié)經(jīng)驗(yàn),下次再戰(zhàn)!
鏈接:http://abc072.contest.atcoder.jp/
A:直接做就可以了
#include<bits/stdc++.h>using namespace std; const int INF = (1 << 30); const int N = 100000 + 5; const double eps = 1e-8; const int M = 100 + 5; const int MOD = 1e9;char str[N]; int main(){int x, t;scanf("%d %d", &x, &t);printf("%d\n", max(x - t, 0)); }?
B:也是直接做就可以了
#include<bits/stdc++.h>using namespace std; const int INF = (1 << 30); const int N = 100000 + 5; const double eps = 1e-8; const int M = 100 + 5; const int MOD = 1e9;char str[N]; int main(){scanf("%s", str);int len = strlen(str);for(int i = 0; i < len; i += 2) putchar(str[i]);puts(""); }?
C:只要考慮a[i+1] + a[i] + a[i+2]就可以了
#include<bits/stdc++.h>using namespace std; const int INF = (1 << 30); const int N = 100000 + 5; const double eps = 1e-8; const int M = 100 + 5; const int MOD = 1e9;int a[N]; int main(){int n, ans = 0, x, maxn = 0;scanf("%d", &n);for(int i = 1; i <= n; i++){scanf("%d", &x); ++ a[x];if(x > maxn) maxn = x;}for(int i = 0; i <= maxn; i++)ans = max(ans, a[i] + a[i + 1] + a[i + 2]);printf("%d\n", ans); }?
D:沒想到這么直接,直接swap就行了,我以為有什么套路結(jié)果卡著半天,最后還剩3分鐘的時(shí)候直接交上去竟然AC了。。。神奇。。。
#include<bits/stdc++.h>using namespace std; const int INF = (1 << 30); const int N = 100000 + 5; const double eps = 1e-8; const int M = 100 + 5; const int MOD = 1e9;int a[N]; int main(){int n, ans = 0;scanf("%d", &n);for(int i = 1; i <= n; i++) scanf("%d", &a[i]);for(int i = 1; i < n; i++)if(a[i] == i) swap(a[i], a[i + 1]), ans++;if(a[n] == n) ans++;printf("%d\n", ans); }?
轉(zhuǎn)載于:https://www.cnblogs.com/Pretty9/p/7468182.html
總結(jié)
以上是生活随笔為你收集整理的AtCoder Beginner Contest 072的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: java利用kafka生产消费消息
- 下一篇: ORM简介