zoukankan      html  css  js  c++  java
  • hdu--2523--读懂题意....

    这题 感觉很容易读错题意的~~

          touch  me

    这题 要是 数据再大点 就不那么容易做了 用hash才2000的数组 太轻松了要是弄个10^9....就要换方法了

    一开始 我一直担心 O(n^2)的去预处理数组 会不会导致超时 ...还好n就1000

    这里的第K大 让我WA了3 4发...  这一定要仔细看清.. =-=

     1 #include <iostream>
     2 #include <cstring>
     3 using namespace std;
     4 
     5 int abs(int n)
     6 {
     7     return n>=0?n:-n;
     8 }
     9 const int size = 2010;
    10 int val[size];
    11 int arr[1010];
    12 
    13 int main()
    14 {
    15     cin.sync_with_stdio(false);
    16     int n , k , t , cnt;
    17     while( cin >> t )
    18     {
    19         while( t-- )
    20         {
    21             cin >> n >> k;
    22             cnt = 0;
    23             memset( val , 0 , sizeof(val) );
    24             for( int i = 0 ; i<n ; i++ )
    25             {
    26                 cin >> arr[i];
    27                 for( int j = 0 ; j<i ; j++ )
    28                 {
    29                     val[ abs( arr[i]-arr[j] ) ] = 1;
    30                 }
    31             }
    32             for( int i = 0 ; i<=size ; i++ )
    33             {
    34                 if( val[i]==1 )
    35                 {
    36                     cnt++;
    37                 }
    38                 if( cnt==k )
    39                 {
    40                     cout << i << endl;
    41                     break;
    42                 }
    43             }
    44         }
    45     }
    46     return 0;
    47 }
    View Code

    today:

      网站到期了 什么都会过期 是吗?

      总有一些是时光冲不走的!

    just follow your heart
  • 相关阅读:
    Mock
    JMeter分布式并发
    APP常见的性能测试指标
    Jmeter模拟微信用户
    jmeter性能测试
    小程序测试注意点
    性能测试常见瓶颈及调优方法
    常见的性能缺陷
    测试理论知识(一)
    ISO9126质量模型
  • 原文地址:https://www.cnblogs.com/radical/p/3870662.html
Copyright © 2011-2022 走看看