2017年4月11日 星期二

POJ 1852 -- Ants - 參考答案

Difficulty: Eazy
Ref: POJ 1852 -- Ants
/*******************************************************/
/* POJ 1852 -- Ants                                    */
/* Author: awei0905  [at]  awei0905.blogspot.tw        */
/* Version: 2017/04/11                                 */
/*******************************************************/
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>

using namespace std;
int main() {
 int N, L, n, x, mT, MT;
 scanf("%d", &N);
 while (N-- && scanf("%d%d", &L, &n)){
  mT = MT = 0;
  for (int i = 0; i < n; i++){
   scanf("%d", &x);
   mT = max(mT, min(x, L - x));
   MT = max(MT, max(x, L - x));
  }
  printf("%d %d\n", mT, MT);
 }
}
Debug: I/O
要特別注意的是:線上測資非常大、非常長!!!
2
10 3
2 6 7
214 7
11 12 7 13 176 23 191
4 8
38 207

沒有留言:

張貼留言