日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

AtCoder Beginner Contest 072

發(fā)布時(shí)間:2025/4/5 编程问答 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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)題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。