2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)
A. Find a Number
找到一个树,可以被d整除,且数字和为s
记忆化搜索
static class S{
int mod,s;
String str;
public S(int mod, int s, String str) {
this.mod = mod;
this.s = s;
this.str = str;
}
}
public static void main(String[] args) {
IO io = new IO();
int[][]vis=new int[550][5500];
int d=io.nextInt(),s=io.nextInt();
Queue<S>q=new ArrayDeque<>(10000);
q.add(new S(0,0,""));
while (!q.isEmpty()){
S cur=q.poll();
if (cur.mod==0&&cur.s==s){
io.println(cur.str);return;
}
for (int i = 0; i <=9; i++) {
int mm=(cur.mod*10+i)%d;
int ss=cur.s+i;
if (vis[mm][ss]==0&&ss<=s){
q.add(new S(mm,ss,cur.str+i));
vis[mm][ss]=1;
}
}
}
io.println(-1);
}
B. Berkomnadzor——我选择狗带……这题目有毒啊
C. Cloud Computing
有m个计划,每个计划的内容是从[l,r]天内,总共有c个处理器,每个p元。问,从[1,n]天,每天买k个处理器(尽量买齐k个)最小花费是多少
线段树表示当天有效的计划,处理器价格就是叶子编号。注意此题要全部开long,tre[i][0]是个数总和,tre[i][1]是价值总和。(才发现把tre拆成两个数组会快一倍)
private static final int c = 1000100;
static long[] S = new long[c << 2];
static long[] sum = new long[c << 2];
static long ans;
static ArrayList<long[]>[] plan = new ArrayList[c]; static void update(int t, int l, int r, long c, long p) {
S[t] += c;
sum[t] += c * p;
if (l == r) return;
int mid = l + r >> 1;
if (p <= mid) update(t << 1, l, mid, c, p);
else update(t << 1 | 1, mid + 1, r, c, p);
} static long query(int t, int l, int r, long k) {
if (k <= 0) return 0;
if (S[t] <= k) return sum[t];
if (l == r) return k * l;
int mid = l + r >> 1;
return query(t << 1, l, mid, k) +
query(t << 1 | 1, mid + 1, r, k - S[t << 1]);
} public static void main(String[] args) {
for (int i = 0; i < plan.length; i++) plan[i] = new ArrayList<>();
IO io = new IO();
int n = io.nextInt(), k = io.nextInt(), m = io.nextInt();
for (int i = 0; i < m; i++) {
int l = io.nextInt(), r = io.nextInt(), c = io.nextInt(), p = io.nextInt();
plan[l].add(new long[]{c, p});
plan[r + 1].add(new long[]{-c, p});
}
for (int i = 1; i <= n; i++) {
for (long[] v : plan[i]) update(1, 1, c, v[0], v[1]);
ans += query(1, 1, c, Math.min(S[1], k));
}
io.println(ans);
}
D. Garbage Disposal
有n天,每天产生ni的垃圾,每个垃圾袋容量为k,每天产生的垃圾最迟第二天要丢掉,第n天的垃圾当天要丢掉,问使用的垃圾袋最少个数
模拟
private static final int c = (int) 2e6;
public static void main(String[] args) {
IO io=new IO();
long n=io.nextLong(),k=io.nextLong();
long[]a=new long[2];
long ans=0;
for (int i=1;i<=n;i++){
int now=i&1,pre=now^1;
long t=io.nextLong();
if (i==n){
ans+=Math.ceil((double)(t+a[pre])/k);
break;
}
if (a[pre]!=0){
ans+=Math.ceil((double) a[pre]/k);
long more=k-a[pre]%k;
t-=more;
if (t<0)t=0;
}
ans+=t/k;
t%=k;
a[now]=t;
}
io.println(ans);
}
2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)的更多相关文章
- 2018.10.20 2018-2019 ICPC,NEERC,Southern Subregional Contest(Online Mirror, ACM-ICPC Rules)
i207M的“怕不是一个小时就要弃疗的flag”并没有生效,这次居然写到了最后,好评=.= 然而可能是退役前和i207M的最后一场比赛了TAT 不过打得真的好爽啊QAQ 最终结果: 看见那几个罚时没, ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror) Solution
从这里开始 题目列表 瞎扯 Problem A Find a Number Problem B Berkomnadzor Problem C Cloud Computing Problem D Gar ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) Solution
A. Find a Number Solved By 2017212212083 题意:$找一个最小的n使得n % d == 0 并且 n 的每一位数字加起来之和为s$ 思路: 定义一个二元组$< ...
- Codeforces1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)总结
第一次打ACM比赛,和yyf两个人一起搞事情 感觉被两个学长队暴打的好惨啊 然后我一直做傻子题,yyf一直在切神仙题 然后放一波题解(部分) A. Find a Number LINK 题目大意 给你 ...
- codeforce1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) 题解
秉承ACM团队合作的思想懒,这篇blog只有部分题解,剩余的请前往星感大神Star_Feel的blog食用(表示男神汉克斯更懒不屑于写我们分别代写了下...) C. Cloud Computing 扫 ...
- 2018-2019 ICPC, NEERC, Southern Subregional Contest
目录 2018-2019 ICPC, NEERC, Southern Subregional Contest (Codeforces 1070) A.Find a Number(BFS) C.Clou ...
- Codeforces 2018-2019 ICPC, NEERC, Southern Subregional Contest
2018-2019 ICPC, NEERC, Southern Subregional Contest 闲谈: 被操哥和男神带飞的一场ACM,第一把做了这么多题,荣幸成为7题队,虽然比赛的时候频频出锅 ...
- 2016-2017 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror) in codeforces(codeforces730)
A.Toda 2 思路:可以有二分来得到最后的数值,然后每次排序去掉最大的两个,或者3个(奇数时). /************************************************ ...
- 【*2000】【2018-2019 ICPC, NEERC, Southern Subregional Contest C 】Cloud Computing
[链接] 我是链接,点我呀:) [题意] [题解] 我们可以很容易知道区间的每个位置有哪些安排可以用. 显然 我们优先用那些花费的钱比较少的租用cpu方案. 但一个方案可供租用的cpu有限. 我们可以 ...
随机推荐
- Hibernate执行SQL语句实现查询修改功能!
今天玩Hibernate时突然就想写写SQL语句查询... DAO : //查询 public List<?> createSqlQueryList(final String queryS ...
- 自反ACL(第三组)
一.实验拓扑 二.配置过程 此处我用了学号后两位来划分网段,注意:先把网络做通再配ACL 1)网络连通测试 内网可以telnet外网 ----------- 外网可以telnet内网 2)ACL配置( ...
- 使用jquery模拟请求,测试项目是否存在跨域限制
1.Get 请求 <html> <head><script src="https://cdn.staticfile.org/jquery/1.10.2/jque ...
- 微信连wifi认证
官网 https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1444894086 https://blog.csdn.net/u0116 ...
- 开源 , KoobooJson一款高性能且轻量的JSON框架
KoobooJson - 更小更快的C# JSON序列化工具(基于表达式树构建) 在C#领域,有很多成熟的开源JSON框架,其中最著名且使用最多的是 Newtonsoft.Json ,然而因为版本迭代 ...
- Vue (三) --- Vue 组件开发
------------------------------------------------------------------好心情,会让你峰回路转. 5. 组件化开发 5.1 组件[compo ...
- springmvc的前端控制器
<servlet> <servlet-name>xxx</servlet-name> <servlet-class>org.springframewor ...
- 从JS的深拷贝与浅拷贝到jq的$.extend()方法
一.堆内存与栈内存 堆和栈都是内存中划分出来的用来存储的区域,栈为自动分配的内存空间,它由系统自动释放,堆为动态分配的内存,大小不定也不会自动释放. 二.js基本数据类型与引用类型的不同 基本数据类型 ...
- java获取文件行数
public long getLineNumber(File file) { if (file.exists()) { try { FileReader fileReader = new FileRe ...
- Oracle数据库启动出现ORA-27101错误之ORA-19815处理方式及数据备份
ORA-27101: sharedmemory realm does not exist之ORA-19815处理 重启数据库(数据库:muphy),登陆是越到错误: ORA-27101: shared ...