今晚 Atcoder AWC 题解
2026-02-09 19:56:58
发布于:广东
!?Atcoder 欢乐赛乐欢 redoctA?!
A
Difficulty:3- / Easy
Tag:-
显然每次繁殖都会增加一个大小。所以答案是 。没了。
namespace cjdst{
void solve(){
ll n;
std::cin >> n;
std::cout << n + 1 << '\n';
}
}
时间复杂度:。
B
Difficulty:3- / Easy
Tag:-
。没了。
namespace cjdst{
void solve(){
int n, l, r;
std::cin >> n >> l >> r;
std::vector <int> a(n + 5);
for(int i = 1; i <= n; i++){
std::cin >> a[i];
}
int cur = -1, ans = -1;
for(int i = 1; i <= n; i++){
if(l <= a[i] && a[i] <= r){
if(ans < a[i]) cur = i, ans = a[i];
}
}
std::cout << cur << '\n';
}
}
时间复杂度:。
C
Difficulty:3- / Easy
Tag:-
显然把优惠券用在价格最大的 个最优。所以从小到大排个序,答案是前 项的和。没了。
namespace cjdst{
void solve(){
int n, m;
std::cin >> n >> m;
std::vector <int> a(n + 5);
for(int i = 1; i <= n; i++){
std::cin >> a[i];
}
std::sort(a.begin() + 1, a.begin() + n + 1);
ll ans = 0;
for(int i = 1; i <= n - m; i++){
ans += a[i];
}
std::cout << ans << '\n';
}
}
时间复杂度:。
D
Difficulty:3- / Easy
Tag:01 背包
定义 表示到了第 个点,还剩 块钱。没了。
namespace cjdst{
void solve(){
int n, m, k;
std::cin >> n >> m >> k;
std::vector <int> a(n + 5), b(n + 5);
for(int i = 1; i <= n; i++){
std::cin >> a[i] >> b[i];
}
std::vector <std::vector <ll>> dp(n + 5, std::vector <ll>(m + 5, -0x3f3f3f3f3f3f3f3fll));
for(int i = 0; i <= n; i++){
dp[i][0] = 0;
}
ll ans = 0;
for(int i = 1; i <= n; i++){
for(int j = b[i]; j <= m; j++){
for(int l = 1; l <= k; l++){
if(l > i) continue;
dp[i][j] = std::max(dp[i][j], dp[i - l][j - b[i]] + a[i]);
}
ans = std::max(ans, dp[i][j]);
}
}
std::cout << ans << '\n';
}
}
时间复杂度:。
Bonus:把它优化到 。
E
Difficulty:3- / Easy
Tag:-
这下看懂老师为什么要在学莫队算法的时候说逛画展了。
双指针模拟即可。没了。
namespace cjdst{
void solve(){
int n, m;
std::cin >> n >> m;
std::vector <int> a(n + 5);
for(int i = 1; i <= n; i++){
std::cin >> a[i];
}
int ans = 0;
std::multiset <int> st;
for(int i = 1; i <= n; i++){
st.insert(a[i]);
if(i > m){
auto it = st.find(a[i - m]);
st.erase(it);
}
ans = std::max(ans, *st.rbegin() - *st.begin());
}
std::cout << ans << '\n';
}
}
时间复杂度:。
全部评论 9
顶
1周前 来自 重庆
1没了
1周前 来自 湖北
0没了
1周前 来自 广东
0没了
1周前 来自 湖北
0[请输入文本]
[]
[没了]Output:[没了]
1周前 来自 浙江
0
d
1周前 来自 浙江
0d
1周前 来自 浙江
0我 D 似乎就差一点做出来了捏
1周前 来自 浙江
0很好看的码风 和我的差不多
1周前 来自 广东
0%
1周前 来自 重庆
0%
1周前 来自 福建
0
This contest is currently in beta phase. At this stage, we allow AI assistance and live streaming/X posts during the competition. Rules are likely to change once we exit beta.
所以我发了没问题吧(
1周前 来自 广东
0包的,这五天AIer爽死
1周前 来自 上海
0
踩
1周前 来自 浙江
0顶
1周前 来自 广东
0
d
1周前 来自 广东
0








































有帮助,赞一个