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 |
Re:这样可算最优解吗?(这题不是模拟哦)In Reply To:这样可算最优解吗?(这题不是模拟哦) Posted by:qddpx at 2012-08-12 06:36:03 即使再優化也是常數級的了。(也許能考慮不用數組?) 我的方法和你的很接近。 #include <iostream> #include <vector> using namespace std; vector<short> p; int main(){ short t, n, i; cin>>t; while(t--){ cin>>n; p.assign(n+1, 0); while(n--){ cin>>p[n]; short i; for(i = n+1; i<p.size() && p[n]-p[i]<i-n; i++); cout << i-n << ' '; } cout<<endl; } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator