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)的更多相关文章

  1. 2018.10.20 2018-2019 ICPC,NEERC,Southern Subregional Contest(Online Mirror, ACM-ICPC Rules)

    i207M的“怕不是一个小时就要弃疗的flag”并没有生效,这次居然写到了最后,好评=.= 然而可能是退役前和i207M的最后一场比赛了TAT 不过打得真的好爽啊QAQ 最终结果: 看见那几个罚时没, ...

  2. 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 ...

  3. 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$ 思路: 定义一个二元组$< ...

  4. Codeforces1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred)总结

    第一次打ACM比赛,和yyf两个人一起搞事情 感觉被两个学长队暴打的好惨啊 然后我一直做傻子题,yyf一直在切神仙题 然后放一波题解(部分) A. Find a Number LINK 题目大意 给你 ...

  5. codeforce1070 2018-2019 ICPC, NEERC, Southern Subregional Contest (Online Mirror, ACM-ICPC Rules, Teams Preferred) 题解

    秉承ACM团队合作的思想懒,这篇blog只有部分题解,剩余的请前往星感大神Star_Feel的blog食用(表示男神汉克斯更懒不屑于写我们分别代写了下...) C. Cloud Computing 扫 ...

  6. 2018-2019 ICPC, NEERC, Southern Subregional Contest

    目录 2018-2019 ICPC, NEERC, Southern Subregional Contest (Codeforces 1070) A.Find a Number(BFS) C.Clou ...

  7. Codeforces 2018-2019 ICPC, NEERC, Southern Subregional Contest

    2018-2019 ICPC, NEERC, Southern Subregional Contest 闲谈: 被操哥和男神带飞的一场ACM,第一把做了这么多题,荣幸成为7题队,虽然比赛的时候频频出锅 ...

  8. 2016-2017 ACM-ICPC, NEERC, Southern Subregional Contest (Online Mirror) in codeforces(codeforces730)

    A.Toda 2 思路:可以有二分来得到最后的数值,然后每次排序去掉最大的两个,或者3个(奇数时). /************************************************ ...

  9. 【*2000】【2018-2019 ICPC, NEERC, Southern Subregional Contest C 】Cloud Computing

    [链接] 我是链接,点我呀:) [题意] [题解] 我们可以很容易知道区间的每个位置有哪些安排可以用. 显然 我们优先用那些花费的钱比较少的租用cpu方案. 但一个方案可供租用的cpu有限. 我们可以 ...

随机推荐

  1. Win 10 和 Ubuntu 16.04 双系统,安装完成后,设置默认的启动项

    当安装好了 Windows 和 Ubuntu 双系统之后,默认的启动项是 Ubuntu,我们可以来设置默认的启动项, 开机时,在启动项选择处,可以通过↑↓ 键来选择启动哪个系统,第一行序号是 0 ,第 ...

  2. git 同步远程分支

    1. 同步远程分支到本地 git fetch 2. 查看本地分支 git branch *dev //当前分支 master test 3.切换分支 git checkout master // 切换 ...

  3. Pandas 数据清洗常用篇

    一.缺失值 sklearn中的preprocessing下有imputer,可进官方文档参考.这里主讲pandas. 拿到数据,一般先检查是否有缺失值,用isnul()或notnull(). 再决定d ...

  4. css display和vertical-align 属性

    display 定义和用法 display 属性规定元素应该生成的框的类型. 实例 <html> <head> <style type="text/css&qu ...

  5. 03SpringBoot用JdbcTemplates访问Mysql

    03SpringBoot用JdbcTemplates访问Mysql 文章指导 学习笔记 学习代码 初始化mysql -- create table `account` DROP TABLE `acco ...

  6. BSScrollViewEdgePop

    https://blog.csdn.net/qq_17190231/article/details/84201956 2018年11月18日 16:52:39 FreeBaiShun 阅读数:66 标 ...

  7. python 三元运算符、推导式、递归、匿名函数、内置函数

    三目运算符 # 三目(元)运算符:就是 if...else...语法糖 # 前提:简化if...else...结构,且两个分支有且只有一条语句 # 注:三元运算符的结果不一定要与条件直接性关系 cmd ...

  8. mysql join用法简介

    为什么需要join 为什么需要join?join中文意思为连接,连接意味着关联即将一个表和多个表之间关联起来.在处理数据库表的时候,我们经常会发现,需要从多个表中获取信息,将多个表的多个字段数据组装起 ...

  9. jQuery在页面加载的时候自动调用某个函数的方法

    第一种:$(document).ready(function(){ func(xxx)//执行函数}); 第二种:$(function(){ func(xxx)//执行函数}); 第三种:jQuery ...

  10. String.Join Method

    Overloads Join(String, String[], Int32, Int32) Concatenates the specified elements of a string array ...