A
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while(t--) {
int n;
cin >> n;
if(n != 1 && (n % 7 == 2 || n % 7 == 0)) cout << "Ah!Shit!" << endl;
else cout << "Deep Dark fantasy!" << endl;
}
return 0;
}
B
#include <iostream>
#include <stack>
using namespace std;
int n, op[200005], cnt[200005];
bool ans[200005];
stack<int> stk[200005];
int main() {
int n;
cin >> n;
for(int i = 1; i <= n; i++) {
int x;
cin >> op[i] >> x;
if(op[i] == 1) stk[x].push(i);
else {
if(stk[x].empty()) {
cout << "qwq" << endl;
return 0;
}
cnt[stk[x].top()]++;
cnt[i]--;
ans[stk[x].top()] = true;
stk[x].pop();
}
}
int maxn = 0, sum = 0;
for(int i = 1; i <= n; i++) {
sum += cnt[i];
maxn = max(maxn, sum);
}
cout << maxn << endl;
for(int i = 1; i <= n; i++) {
if(op[i] == 1) cout << ans[i] << ' ';
}
return 0;
}
D
#include <iostream>
#include <cstring>
#define ll long long
using namespace std;
ll w[100005], v[100005], f[100005];
int main() {
ll n, t, sum = 0;
cin >> n >> t;
for(int i = 1; i <= n; i++) {
int x, y, z;
cin >> x >> y >> v[i];
w[i] = x - y;
sum += v[i];
}
memset(f, 0x3f, sizeof(f));
f[0] = 0;
for(int i = 1; i <= n; i++) {
for(int j = sum; j >= v[i]; j--) {
f[j] = min(f[j], f[j - v[i]] + w[i]);
}
}
for(int i = sum; i >= 0; i--) {
if(f[i] <= t) {
cout << i << endl;
break;
}
}
return 0;
}