- 老爷爷与老奶奶
- 2015-08-09 09:43:36 @
program exercise(input,output);
var n,x,y,i:longint;
a:array[0..100001]of longint;
begin
readln(n);
x:=200001;
y:=0;
for i:=0 to n-1 do
begin
read(a[i]);
if x>a[i] then
begin
x:=a[i];
y:=i;
end;
end;
readln;
for i:=y to y+n-2 do
if a[i mod n]>a[(i+1) mod n] then
begin
writeln(-1);
exit;
end;
writeln((n-y) mod n);
end.
2 条评论
-
q234rty LV 10 @ 2015-08-09 10:37:00
这题我比赛的时候也是这个思路,结果和你一样WA76,后来自己想出了正解。
数据:
4
3 4 3 3
正确答案是2,你WA了。
思考一下,当有多个最小值的情况下应输出什么呢?
如果想不出来,可以去看我的题解(进入题解区,Ctrl+F q234rty) -
2015-08-09 09:43:57@
测试数据 #0: WrongAnswer, time = 0 ms, mem = 1156 KiB, score = 0
测试数据 #1: WrongAnswer, time = 0 ms, mem = 1156 KiB, score = 0
测试数据 #2: Accepted, time = 0 ms, mem = 1152 KiB, score = 2
测试数据 #3: Accepted, time = 31 ms, mem = 1156 KiB, score = 2
测试数据 #4: Accepted, time = 31 ms, mem = 1152 KiB, score = 2
测试数据 #5: Accepted, time = 15 ms, mem = 1152 KiB, score = 2
测试数据 #6: Accepted, time = 51 ms, mem = 1152 KiB, score = 2
测试数据 #7: Accepted, time = 31 ms, mem = 1156 KiB, score = 2
测试数据 #8: Accepted, time = 15 ms, mem = 1152 KiB, score = 2
测试数据 #9: Accepted, time = 70 ms, mem = 1152 KiB, score = 2
测试数据 #10: Accepted, time = 31 ms, mem = 1152 KiB, score = 2
测试数据 #11: Accepted, time = 31 ms, mem = 1152 KiB, score = 2
测试数据 #12: Accepted, time = 15 ms, mem = 1148 KiB, score = 2
测试数据 #13: Accepted, time = 31 ms, mem = 1152 KiB, score = 2
测试数据 #14: Accepted, time = 41 ms, mem = 1156 KiB, score = 2
测试数据 #15: Accepted, time = 48 ms, mem = 1156 KiB, score = 2
测试数据 #16: Accepted, time = 31 ms, mem = 1152 KiB, score = 2
测试数据 #17: Accepted, time = 31 ms, mem = 1152 KiB, score = 2
测试数据 #18: Accepted, time = 31 ms, mem = 1152 KiB, score = 2
测试数据 #19: Accepted, time = 42 ms, mem = 1152 KiB, score = 2
测试数据 #20: Accepted, time = 1 ms, mem = 1152 KiB, score = 2
测试数据 #21: WrongAnswer, time = 4 ms, mem = 1152 KiB, score = 0
测试数据 #22: WrongAnswer, time = 1 ms, mem = 1152 KiB, score = 0
测试数据 #23: Accepted, time = 2 ms, mem = 1152 KiB, score = 2
测试数据 #24: Accepted, time = 18 ms, mem = 1152 KiB, score = 2
测试数据 #25: Accepted, time = 15 ms, mem = 1148 KiB, score = 2
测试数据 #26: Accepted, time = 83 ms, mem = 1152 KiB, score = 2
测试数据 #27: Accepted, time = 0 ms, mem = 1152 KiB, score = 2
测试数据 #28: Accepted, time = 0 ms, mem = 1152 KiB, score = 2
测试数据 #29: Accepted, time = 0 ms, mem = 1152 KiB, score = 2
测试数据 #30: WrongAnswer, time = 1 ms, mem = 1152 KiB, score = 0
测试数据 #31: Accepted, time = 0 ms, mem = 1152 KiB, score = 2
测试数据 #32: Accepted, time = 0 ms, mem = 1156 KiB, score = 2
测试数据 #33: Accepted, time = 0 ms, mem = 1152 KiB, score = 2
测试数据 #34: Accepted, time = 0 ms, mem = 1152 KiB, score = 2
测试数据 #35: WrongAnswer, time = 1 ms, mem = 1152 KiB, score = 0
测试数据 #36: WrongAnswer, time = 0 ms, mem = 1152 KiB, score = 0
测试数据 #37: Accepted, time = 2 ms, mem = 1156 KiB, score = 2
测试数据 #38: Accepted, time = 2 ms, mem = 1156 KiB, score = 2
测试数据 #39: Accepted, time = 0 ms, mem = 1152 KiB, score = 2
测试数据 #40: Accepted, time = 15 ms, mem = 1152 KiB, score = 2
测试数据 #41: Accepted, time = 0 ms, mem = 1156 KiB, score = 2
测试数据 #42: Accepted, time = 0 ms, mem = 1156 KiB, score = 2
测试数据 #43: WrongAnswer, time = 3 ms, mem = 1152 KiB, score = 0
测试数据 #44: WrongAnswer, time = 15 ms, mem = 1152 KiB, score = 0
测试数据 #45: WrongAnswer, time = 3 ms, mem = 1148 KiB, score = 0
测试数据 #46: WrongAnswer, time = 4 ms, mem = 1156 KiB, score = 0
测试数据 #47: Accepted, time = 3 ms, mem = 1152 KiB, score = 2
测试数据 #48: Accepted, time = 0 ms, mem = 1152 KiB, score = 2
测试数据 #49: WrongAnswer, time = 6 ms, mem = 1156 KiB, score = 0
WrongAnswer, time = 755 ms, mem = 1156 KiB, score = 76
- 1