<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當(dāng)前位置: 首頁 - 科技 - 知識(shí)百科 - 正文

        codeforcesRound#259(div2)B解題報(bào)告

        來源:懂視網(wǎng) 責(zé)編:小采 時(shí)間:2020-11-09 08:01:18
        文檔

        codeforcesRound#259(div2)B解題報(bào)告

        codeforcesRound#259(div2)B解題報(bào)告:B. Little Pony and Sort by Shift time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day, Twilight Sparkle is interested in how to sort a sequence of integers a 1 , a 2 。.。
        推薦度:
        導(dǎo)讀codeforcesRound#259(div2)B解題報(bào)告:B. Little Pony and Sort by Shift time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day, Twilight Sparkle is interested in how to sort a sequence of integers a 1 , a 2 。.。

        解法:

        也是一道很easy的編程基礎(chǔ)題,找出兩隊(duì)單調(diào)非遞減序列,分別為1~x 和 x+1~y,判斷這兩隊(duì)是否覆蓋整串?dāng)?shù)字,且a[n] <= a[1]。

        更簡(jiǎn)單的一種做法就是,將a[1]~a[n]復(fù)制一遍,拓展到a[1]~a[2*n],然后在1 ~ 2*n里面找,是否有一串單調(diào)不遞減的個(gè)數(shù)為n的序列。

        代碼:

        #include 
        #define N_max 123456
        
        int n, x, y, cnt;
        int a[N_max];
        
        void init() {
        	scanf("%d", &n);
        	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
        }
        
        void solve() {
        	for (int i = 1; i <= n; i++)
        	if (a[i] > a[i+1]) {
        	x = i;
        	break;
        	}
        
        	if (x == n)
        	y = n;
        	else
        	for (int i = x+1; i <= n; i++)
        	if (a[i] > a[i+1]) {
        	y = i;
        	break;
        	}
        
        	if (x == n)
        	printf("0\n");
        	else if (y == n && a[y] <= a[1])
        	printf("%d\n", y-x);
        	else
        	printf("-1\n");
        }
        
        int main() {
        	init();
        	solve();
        }

        聲明:本網(wǎng)頁內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        codeforcesRound#259(div2)B解題報(bào)告

        codeforcesRound#259(div2)B解題報(bào)告:B. Little Pony and Sort by Shift time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One day, Twilight Sparkle is interested in how to sort a sequence of integers a 1 , a 2 。.。
        推薦度:
        標(biāo)簽: 解題 round Codeforces
        • 熱門焦點(diǎn)

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: h片在线观看免费| 亚洲成aⅴ人片在线影院八| 亚洲欧美成人综合久久久| 最近免费中文字幕mv在线电影| 国产亚洲大尺度无码无码专线| 亚洲精品无码激情AV| 久久久久亚洲AV无码去区首| 大学生a级毛片免费观看| 久久亚洲精品国产亚洲老地址| 亚洲国产高清国产拍精品| a级毛片视频免费观看| 最近免费中文字幕视频高清在线看| 97久久国产亚洲精品超碰热| 毛片免费vip会员在线看| 亚洲精品无码成人| 国产免费观看黄AV片| 亚洲国产精品久久66| 四虎免费影院ww4164h| 免费欧洲美女牲交视频| 一级做a毛片免费视频| 亚洲福利在线观看| 成人免费的性色视频| 国产AV无码专区亚洲AWWW| 成人A片产无码免费视频在线观看 成人电影在线免费观看 | 处破痛哭A√18成年片免费| 精品一区二区三区无码免费直播| 亚洲精品国产日韩无码AV永久免费网 | 亚洲精品中文字幕| 亚洲国产综合精品一区在线播放| 国产免费无码一区二区| 亚洲国产成人久久三区| 免费在线观看黄网| 99久久婷婷国产综合亚洲| 亚洲国产精品一区二区第四页| 亚洲中文字幕无码久久| 亚洲一区二区三区在线播放| 日韩免费无码一区二区三区| 亚洲一线产品二线产品| 亚洲国产精品VA在线观看麻豆| 免费福利在线观看| 久久精品九九亚洲精品|