Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
确实比较水啊~O(n)的啊怎么还110ms#include <iostream> #include <stdio.h> using namespace std; int main() { int N; scanf("%d", &N); int q = 0, h; int state = 0;//0:正在上升 1:下降 for(int i = 0; i <= N; i++){ if(i < N) scanf("%d", &h); else h = 0; if(state == 0 && h > q){ q = h; } else if(state == 0 && h == q){ printf("%d\n", i); } else if(state == 0 && h < q){ state = 1; printf("%d\n", i); q = h; } else if(h > q){ state = 0; q = h; } else if(h == q){ state = 0; } else{ q = h; } } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator