Skip to content

Instantly share code, notes, and snippets.

@whatalnk
Created May 4, 2017 04:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whatalnk/c2536aa4cbe6aa68367fa4fb3c22a5cc to your computer and use it in GitHub Desktop.
Save whatalnk/c2536aa4cbe6aa68367fa4fb3c22a5cc to your computer and use it in GitHub Desktop.
アリ本 1-6 p23 Ants(POJ では Runtime error ??)
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX_N = 10 ^ 6;
int N;
int L, n;
int x[MAX_N];
void solve()
{
int minT = 0;
for (int i = 0; i < n; i++)
{
minT = max(minT, min(x[i], L - x[i]));
}
int maxT = 0;
for (int i = 0; i < n; i++)
{
maxT = max(maxT, max(x[i], L - x[i]));
}
cout << minT << " " << maxT << endl;
}
int main()
{
ios::sync_with_stdio(false);
cin >> N;
for (int i = 0; i < N; i++)
{
cin >> L >> n;
for (int j = 0; j < n; j++)
{
cin >> x[j];
}
solve();
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment