A. Exponential Plant
模拟
代码实现
h = int(input())
now, day = 0, 0
while now <= h:
now += 1<<day
day += 1
print(day)
B. AtCoder Janken 2
模拟
代码实现
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
int n;
cin >> n;
vector<pair<string, int>> user;
int t = 0;
rep(i, n) {
string s; int c;
cin >> s >> c;
user.emplace_back(s, c);
t += c;
}
sort(user.begin(), user.end());
string ans = user[t%n].first;
cout << ans << '\n';
return 0;
}
C. AtCoder Magics
其实就是找二维平面上以 \(a_i\) 最大的点结尾的最长严格上升点列
代码实现
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n), c(n);
rep(i, n) cin >> a[i] >> c[i];
vector<int> is(n);
iota(is.begin(), is.end(), 0);
sort(is.begin(), is.end(), [&](int i, int j) {
return a[i] > a[j];
});
vector<int> ans;
for (int i : is) {
if (!ans.size() or c[ans.back()] > c[i]) {
ans.push_back(i);
}
}
sort(ans.begin(), ans.end());
cout << ans.size() << '\n';
for (int i : ans) cout << i+1 << ' ';
return 0;
}