codeforces Round #259(div2) B解題報(bào)告_html/css_WEB-ITnose
Jun 24, 2016 am 11:55 AM
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?a1,?a2,?...,?an?in non-decreasing order. Being a young unicorn, the only operation she can perform is a unit shift. That is, she can move the last element of the sequence to its beginning:
a1,?a2,?...,?an?→?an,?a1,?a2,?...,?an?-?1.Help Twilight Sparkle to calculate: what is the minimum number of operations that she needs to sort the sequence?
Input
The first line contains an integer?n?(2?≤?n?≤?105). The second line contains?n?integer numbers?a1,?a2,?...,?an?(1?≤?ai?≤?105).
Output
If it's impossible to sort the sequence output?-1. Otherwise output the minimum number of operations Twilight Sparkle needs to sort it.
Sample test(s)
input
22 1
output
input
31 3 2
output
-1
input
21 2
output
題目大意:
給出N個(gè)數(shù)字,可以每一次將最后一個(gè)數(shù)字移動到最前面,要求最終狀態(tài)是一個(gè)單調(diào)非遞減的序列,求最少需要花多少次操作。如若無法達(dá)到目標(biāo)則輸出“-1"。
解法:
也是一道很easy的編程基礎(chǔ)題,找出兩隊(duì)單調(diào)非遞減序列,分別為1~x 和 x+1~y,判斷這兩隊(duì)是否覆蓋整串?dāng)?shù)字,且a[n]
更簡單的一種做法就是,將a[1]~a[n]復(fù)制一遍,拓展到a[1]~a[2*n],然后在1 ~ 2*n里面找,是否有一串單調(diào)不遞減的個(gè)數(shù)為n的序列。
代碼:
#include <cstdio>#define N_max 123456int n, x, y, cnt;int a[N_max];void init() { scanf("%d", &n); for (int i = 1; i a[i+1]) { x = i; break; } if (x == n) y = n; else for (int i = x+1; i a[i+1]) { y = i; break; } if (x == n) printf("0\n"); else if (y == n && a[y] <p></p> </cstdio>

? AI ??

Undress AI Tool
??? ???? ??

Undresser.AI Undress
???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover
???? ?? ???? ??? AI ?????.

Clothoff.io
AI ? ???

Video Face Swap
??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

?? ??

??? ??

???++7.3.1
???? ?? ?? ?? ???

SublimeText3 ??? ??
??? ??, ???? ?? ????.

???? 13.0.1 ???
??? PHP ?? ?? ??

???? CS6
??? ? ?? ??

SublimeText3 Mac ??
? ??? ?? ?? ?????(SublimeText3)

HTMLHEAD? ?? ???? SEO, ?? ?? ? ???? ??? ?????. 1. ??? ??? ??? ????, ???? ???? ???? ??????. 2. OpenGraph ? Twitter ?? ??? ???? ?? ?? ??? ????? ??? ?????? ???? ??? ??? ???? ???????. 3. ?? ?? ? ??? ??? ???? ??? ??? ??? ???? ????????. 4. ?? ???, ?? ?? ? ?? ?? ?? ???? ?? ??? ??? ????? ???????.

Tolearnhtmlin2025, chooSeatUtoriorialThatthatthath and-practicewithmoderndardAndardsandegratescssandjavaScriptBasics.1.

???? ??? HTML ?? ???? ??? ??? ?????? ?? Div Flex ?? ??? ????? ???? ??? ?????? ??? ???????. ??, ?? ???? ?????? ?? CSS? ?? ? ?? ????. ?? ?? ??? ALT ??? ?? ???? ?? URL? ?????? ??? ???? ??? ?? TD? ??????????. ????? ?? ?????? ?? ??? ????? ???????.

???, ID, ???, ??? ? ??? HTML?? ?? ????? ???? ??? ?????. ???? ??? ?? ? JavaScript ??? ?????? ?? ?? ??? ??? ??? ???? ? ?????. ID? ?? ?? ? JavaScript ???? ??? ??? ?? ?? ???? ?????. ???? ???? ??? ???? ?? ? ? ??? ?? ???? ????? ??? ???? ???? ????. ??? ??? ??? ?? ???? ???? ? ????, ?? ??? ?? ? ??? ?? ??? ?????. ??? ??? ?? ????? ???? ? ????? ???? ??? ????? ?? ?????. ??? ??? ????? ???? ?? ???? ??? ??? ???? ? ????.

??? ??? ??? HTML ?? ??? ??? ????? ?? ?? ?? ?? ???? ?? ?? ? ? ????. ?? ???? ??? ?????. 1. JavaScript? ???? ?? ?? ? ??? ???? ???? ?? ?? ??? ?? ?? ? ???? ???? ????. 2. Formspree? ?? ?? ???? ? ???? ???? ???? ???? ??? ?? ? ???? ??? ?????. 3. LocalStorage? ???? ??? ?? ??? ????? ?? ??? ?? ???? ??? ???? ? ????? ??? ??? ?? ???? ???? ????.

Native Lazy Loading? ?? ???? ????,?? = "???"??? ??? ???? ??? ????? ? ? ????. 1. JavaScript ?? ?? ?????? ???? ??? HTML?? ?? ?????. 2. ??? ??? ? ?? ??? ???? ?? ??, ?? ??? ??? ??? ? ? ?? ???? ?????. 3. ? ?? ?? ?? ???????? ???? ???? ????. 4. ??? ??? ?, ??? ?? ???? ???? ??? ??? ?? ???????. 5. SRCSET ? ?? ??? ?? ?? ? ??? ??? ????????. 6. ??? ??? ???????. ?? ??? ??????? ???? ????. ?? ??? ?? ??? ? ??? JavaScript ???? ?? ? ? ????.

? ???? ??? ??? ????? ?? HTML ??? ???? ???? ?? ??? ????? ????. 1. ??? ???? ???? CSS ????? ???? ??? ?? ?? ??? ?????. 2. ??? ??? ????? .mp4 ? Webm? ???? ???? ?????. 3. ??? ???? ?? ??? ???? ?? Muted ? PlaySinline ??? ??????. 4. ?? ??? ????? ?? ??? ??? ???? ?? MB? ???? ?? ????. 5. ??? ?? ??? ???? ?? ??? ??????. 6. ?? ?? ?? ?? ??? ???? ??? ? ??? ???? ?? ? ?? ?? ??? ???? ?? ??? ?????. ?? ??? ????? ???? ??? ??? ?? ? ? ????.

IFRAMES? ?????? ?? ??? CSS? ???? ???? ???? ?? ????? ???? ??? ???? ????. 1. ?? ??? ???? ?? ??? ???? ??? ????. 16 : 9? ?? ???? ??? ?? -TOP56.25%, 4 : 3? ????, 4 : 3? 75%? ???? 1 : 1? 100%? ????; 2. iframe ??? 100%? ???? ?? ??? ???? ????? ???? ??-?? ??? ???? ??? ??????. 3. ?? ???? ???? ?? ? ?? ???? ??? ?? ??? ???? ?? ? ?? ??? ???? ??? ????? ?? ?? ??? ????? ??????. Iframe? ?? ?? ???? ?? ???? ? ?? ??? ???????.
