AtCoder Beginner Contest 072
生活随笔
收集整理的這篇文章主要介紹了
AtCoder Beginner Contest 072
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
這應該是我第二次打AtCoder, 題目其實并不難,就是自己經驗不足想復雜了,再加上自己很笨,愣是做了97分鐘才全做出來(最后三分鐘,有點小激動。。),看著前面大牛半個小時都搞完了,真心膜拜一下,代碼其實沒什么可看的,題目也沒什么可說的,就是為了貼出來總結經驗,下次再戰!
鏈接: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就行了,我以為有什么套路結果卡著半天,最后還剩3分鐘的時候直接交上去竟然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); }?
轉載于:https://www.cnblogs.com/Pretty9/p/7468182.html
總結
以上是生活随笔為你收集整理的AtCoder Beginner Contest 072的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java利用kafka生产消费消息
- 下一篇: ORM简介