1、求最小时间
思路:简单的模拟 + 木桶效应
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
const ll N = 2e5 + 5;
const ll mod = 1e9 + 7;
ll a[N];
void solve()
{
ll n, x, y;
cin >> n >> x >> y;
ll ans = 0;
ll d = min(x, y);
ans = n / d;
if (n % d)
ans++;
cout << ans << "\n";
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int t = 1; cin >> t;
while (t--)
{
solve();
}
}
2.Battle for Survive
#include<iostream>
using namespace std;
const int N = 200010;
typedef long long ll;
ll a[N];
void solve()
{
ll n;
cin >> n;
ll ans = 0;
for (int i = 1; i <= n; i++) cin >> a[i];
for (int i = 1; i < n - 1; i++)
{
ans += a[i];
}
ll res = a[n - 1] - ans;
cout << a[n] - res << endl;
}
int main()
{
int t;
cin >> t;
while (t--)
{
solve();
}
return 0;
}