其他分享
首页 > 其他分享> > P1007-独木桥

P1007-独木桥

作者:互联网

 1 #include <bits/stdc++.h>
 2 typedef long long ll;
 3 using namespace std;
 4 #define _for(i,a,b) for(int i = (a);i < b;i ++)
 5 #define _rep(i,a,b) for(int i = (a);i > b;i --)
 6 #define INF 0x3f3f3f3f
 7 #define MOD 1000000007
 8 #define pb push_back
 9 #define maxn 100003
10 
11 inline ll read()
12 {
13     ll ans = 0;
14     char ch = getchar(), last = ' ';
15     while(!isdigit(ch)) last = ch, ch = getchar();
16     while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
17     if(last == '-') ans = -ans;
18     return ans;
19 }
20 inline void write(ll x)
21 {
22     if(x < 0) x = -x, putchar('-');
23     if(x >= 10) write(x / 10);
24     putchar(x % 10 + '0');
25 }
26 int L;
27 int N;
28 int a[5003];
29 int main()
30 {
31     L = read();
32     N = read();
33     _for(i,1,N+1)
34         a[i] = read();
35     
36     int ans1 = 0,ans2 = 0;
37     _for(i,1,N+1)
38     {
39         ans1 = max(ans1,min(a[i],L-a[i]+1));
40         ans2 = max(ans2,max(a[i],L-a[i]+1));
41     //    cout << a[i] << " " << L-a[i] << endl;
42     }
43     printf("%d %d\n",ans1,ans2);
44     return 0;
45 }

 

标签:10,独木桥,ch,int,P1007,ans2,read,define
来源: https://www.cnblogs.com/Asurudo/p/11567253.html