Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:这样可算最优解吗?(这题不是模拟哦)

Posted by danielzhou at 2012-09-20 23:14:57 on Problem 1068
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator