Skip to content

Instantly share code, notes, and snippets.

@sourabhxyz
Created December 15, 2018 15:35
Show Gist options
  • Save sourabhxyz/4af5bc294ab613057de828b308da587a to your computer and use it in GitHub Desktop.
Save sourabhxyz/4af5bc294ab613057de828b308da587a to your computer and use it in GitHub Desktop.
#include<bits/stdc++.h>
using namespace std;
#define inf 10000000
void solve() {
int tc;
cin >> tc;
while (tc--) {
int n, t, m;
cin >> n >> t >> m;
vector<int> ferr(m);
for (int i = 0; i < m; i++) cin >> ferr[i];
t *= 2;
int tot = 0;
for (int i = (m % n == 0 ? n - 1 : m % n - 1); i < m; i += n) {
tot = t + max(tot, ferr[i]);
}
cout << tot - t / 2 << " " << (m + n - 1) / n << "\n";
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
//freopen("ina.txt", "r", stdin);
//freopen("outa.txt", "w", stdout);
solve();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment