wei shen me

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 条评论

  • @ 2015-08-09 10:37:00

    这题我比赛的时候也是这个思路,结果和你一样WA76,后来自己想出了正解。
    数据:
    4
    3 4 3 3
    正确答案是2,你WA了。
    思考一下,当有多个最小值的情况下应输出什么呢?
    如果想不出来,可以去看我的题解(进入题解区,Ctrl+F q234rty)

    • @ 2015-08-09 12:45:04

      多谢。AC了。

      编译成功

      Free Pascal Compiler version 2.6.4 [2014/03/06] for i386
      Copyright (c) 1993-2014 by Florian Klaempfl and others
      Target OS: Win32 for i386
      Compiling foo.pas
      Linking foo.exe
      24 lines compiled, 0.1 sec , 28192 bytes code, 1628 bytes data
      测试数据 #0: Accepted, time = 0 ms, mem = 1156 KiB, score = 2
      测试数据 #1: Accepted, time = 11 ms, mem = 1148 KiB, score = 2
      测试数据 #2: Accepted, time = 21 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 = 1156 KiB, score = 2
      测试数据 #6: Accepted, time = 31 ms, mem = 1160 KiB, score = 2
      测试数据 #7: Accepted, time = 35 ms, mem = 1152 KiB, score = 2
      测试数据 #8: Accepted, time = 15 ms, mem = 1148 KiB, score = 2
      测试数据 #9: Accepted, time = 31 ms, mem = 1160 KiB, score = 2
      测试数据 #10: Accepted, time = 31 ms, mem = 1156 KiB, score = 2
      测试数据 #11: Accepted, time = 15 ms, mem = 1152 KiB, score = 2
      测试数据 #12: Accepted, time = 31 ms, mem = 1152 KiB, score = 2
      测试数据 #13: Accepted, time = 31 ms, mem = 1152 KiB, score = 2
      测试数据 #14: Accepted, time = 32 ms, mem = 1152 KiB, score = 2
      测试数据 #15: Accepted, time = 52 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 = 15 ms, mem = 1152 KiB, score = 2
      测试数据 #19: Accepted, time = 31 ms, mem = 1152 KiB, score = 2
      测试数据 #20: Accepted, time = 0 ms, mem = 1152 KiB, score = 2
      测试数据 #21: Accepted, time = 2 ms, mem = 1156 KiB, score = 2
      测试数据 #22: Accepted, time = 3 ms, mem = 1152 KiB, score = 2
      测试数据 #23: Accepted, time = 15 ms, mem = 1152 KiB, score = 2
      测试数据 #24: Accepted, time = 0 ms, mem = 1156 KiB, score = 2
      测试数据 #25: Accepted, time = 0 ms, mem = 1156 KiB, score = 2
      测试数据 #26: Accepted, time = 1 ms, mem = 1148 KiB, score = 2
      测试数据 #27: Accepted, time = 1 ms, mem = 1152 KiB, score = 2
      测试数据 #28: Accepted, time = 1 ms, mem = 1148 KiB, score = 2
      测试数据 #29: Accepted, time = 0 ms, mem = 1156 KiB, score = 2
      测试数据 #30: Accepted, time = 1 ms, mem = 1156 KiB, score = 2
      测试数据 #31: Accepted, time = 3 ms, mem = 1152 KiB, score = 2
      测试数据 #32: Accepted, time = 0 ms, mem = 1152 KiB, score = 2
      测试数据 #33: Accepted, time = 15 ms, mem = 1152 KiB, score = 2
      测试数据 #34: Accepted, time = 0 ms, mem = 1152 KiB, score = 2
      测试数据 #35: Accepted, time = 4 ms, mem = 1160 KiB, score = 2
      测试数据 #36: Accepted, time = 0 ms, mem = 1152 KiB, score = 2
      测试数据 #37: Accepted, time = 0 ms, mem = 1152 KiB, score = 2
      测试数据 #38: Accepted, time = 1 ms, mem = 1152 KiB, score = 2
      测试数据 #39: Accepted, time = 3 ms, mem = 1152 KiB, score = 2
      测试数据 #40: Accepted, time = 15 ms, mem = 1152 KiB, score = 2
      测试数据 #41: Accepted, time = 15 ms, mem = 1152 KiB, score = 2
      测试数据 #42: Accepted, time = 1 ms, mem = 1148 KiB, score = 2
      测试数据 #43: Accepted, time = 0 ms, mem = 1156 KiB, score = 2
      测试数据 #44: Accepted, time = 30 ms, mem = 1156 KiB, score = 2
      测试数据 #45: Accepted, time = 0 ms, mem = 1156 KiB, score = 2
      测试数据 #46: Accepted, time = 0 ms, mem = 1152 KiB, score = 2
      测试数据 #47: Accepted, time = 3 ms, mem = 1152 KiB, score = 2
      测试数据 #48: Accepted, time = 1 ms, mem = 1152 KiB, score = 2
      测试数据 #49: Accepted, time = 3 ms, mem = 1156 KiB, score = 2
      Accepted, time = 639 ms, mem = 1160 KiB, score = 100

  • @ 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

信息

ID
1925
难度
5
分类
其他 | 数学 点击显示
标签
(无)
递交数
292
已通过
111
通过率
38%
被复制
2
上传者