AtCoder Tak and Hotels】的更多相关文章

传送门 一道有意思的题. 一开始想错了,以为一直lowerlowerlower_boundboundbound就可以解决询问,结果交上去TLE了之后才发现时间复杂度是错的. 但是贪心思想一定是对的,每次向前尽量推进一定可以得到最优解. 于是我想起了一道叫做弹飞绵羊的题,感觉这道题可以类比. 码了一会一直WA感觉不太对,发现有一个细节写错了233. A了之后在csdn上翻了翻题解. 发现都是倍增优化%%%,我被自己的低智商给蠢哭了,是啊连修改操作都没有分块很low啊. 不过还是讲讲如何分块吧. 对…
题目链接:传送门 题目大意:有 n 个点排成一条直线,每次行动可以移动不超过 L 的距离,每次行动完成必须停在点上, 数据保证有解,有 m 组询问,问从 x 到 y 最少需要几次行动? 题目思路:倍增 dp[i][j] 表示从 j 出发用 (1<<i)次行动可达的最靠左的端点. #include <iostream> #include <cstdio> #include <cstdlib> #include <cmath> #include &l…
高橋君とホテル / Tak and Hotels Time limit : 3sec / Stack limit : 256MB / Memory limit : 256MB Score : 700 points Problem Statement N hotels are located on a straight line. The coordinate of the i-th hotel (1≤i≤N) is xi. Tak the traveler has the following t…
6463: Tak and Hotels II 时间限制: 1 Sec  内存限制: 128 MB 题目描述 N hotels are located on a straight line. The coordinate of the i-th hotel (1≤i≤N) is xi.Tak the traveler has the following two personal principles:He never travels a distance of more than L in a…
Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement There is a hotel with the following accommodation fee: X yen (the currency of Japan) per night, for the first K nights Y yen per night, for the (K+1)-th and subsequent nigh…
传送门 背包经典题. 直接f[i][j]f[i][j]f[i][j]表示选i张牌和为j的方案数. 最后统计答案就行了. 代码: #include<bits/stdc++.h> #define N 55 #define ll long long using namespace std; ll f[N][N*N],ans=0; int x,a,n; int main(){ f[0][0]=1,scanf("%d%d",&n,&a); for(int i=1;i&…
前言: 因为要普及了,今年没一等就可以退役去学文化课了,所以暑假把历年noip普及组都刷了一遍,离noip还有50+天,想弄点强化训练什么的. 想了想,就这些天学文化课之余有空就把AtCoder之前那些ARC 的 C D E 什么的刷一下吧(一般是D,可能会有简单一点的E和难一点的C)(可能会很慢,毕竟基本有时间也就周末了) 所以就开了这个坑鞭策一下自己,上个坑是dp的,开了50题,补的巨累...这次吸取教训,只开20题...(也没那么多时间去刷题了) 不会说题意,题意的话可以上网找或者去原站看…
Choosing Points 数学 Integers on a Tree 构造 Leftmost Ball 计数dp+组合数学 Painting Graphs with AtCoDeer tarjan+polya Building Cubes with AtCoDeer 枚举 AtCoDeer and Election Report 贪心 Snuke's Coloring 思维题 Snuke's Coloring 2 线段树+单调栈 Make Them Even 贪心 1D Reversi 模…
一句话题解 因为上篇AGC的写的有点长……估计这篇也短不了所以放个一句话题解方便查阅啥的吧QwQ 具体的题意代码题解还是往下翻…… ARC 058 D:简单容斥计数. E:用二进制表示放的数字,然后状压$DP$. F:$biset$优化$DP$预处理,乱搞贪心. ARC 059 D:傻题,存在长的合法子串就一定会存在短的. E:前缀和优化$DP$. F:每个长度为$len$的串出现的概率是相同的,求到长度为$len$的方案数然后除$2^{len}$. ARC 060 D:对$b$分大于根号和小于…
ARC060 C - 高橋君とカード / Tak and Cards 每个数减去A,然后转移N次,每次选或不选,最后是和为0的时候的方案数,负数可以通过把所有数右移2500做到 #include <bits/stdc++.h> #define fi first #define se second #define pii pair<int,int> #define mp make_pair #define pb push_back #define space putchar(' ')…