美文网首页
2019-08-03 贪心四题

2019-08-03 贪心四题

作者: saploser | 来源:发表于2019-08-03 20:47 被阅读0次

P1190 接水问题

第一次提交,“不能定义time变量” ;修改变量名后,AC;为什么Dev-C里面没报错呢?
神奇的CE了,完全看不懂洛谷编译器显示的东西

/tmp/tmpjcx93_mx/src:7:17: 错误:‘int time [10010]’被重新声明为不同意义的符号
int time[NR + 10] ;
^
In file included from /usr/include/pthread.h:24,
from /usr/include/x86_64-linux-gnu/c++/8/bits/gthr-default.h:35,
from /usr/include/x86_64-linux-gnu/c++/8/bits/gthr.h:148,
from /usr/include/c++/8/ext/atomicity.h:35,
from /usr/include/c++/8/bits/ios_base.h:39,
from /usr/include/c++/8/ios:42,
from /usr/include/c++/8/ostream:38,
from /usr/include/c++/8/iostream:39,
from /tmp/tmpjcx93_mx/src:1:
/usr/include/time.h:75:15: 附注:previous declaration ‘time_t time(time_t)’
extern time_t time (time_t __timer) __THROW;
^~~~
/tmp/tmpjcx93_mx/src: 在函数‘int main()’中:
/tmp/tmpjcx93_mx/src:16:23: 警告:在算术表达式中使用了函数指针 [-Wpointer-arith]
scanf("%d" , &time[i]) ;
^
/tmp/tmpjcx93_mx/src:16:9: 警告:格式 ‘%d’ expects argument of type ‘int
’, but argument 2 has type ‘time_t (
)(time_t) throw ()’ {aka ‘long int ()(long int*)’} [-Wformat=]
scanf("%d" , &time[i]) ;
^~~~ ~~~~~~~~
/tmp/tmpjcx93_mx/src:26:25: 警告:在算术表达式中使用了函数指针 [-Wpointer-arith]
tap[tap_min] += time[i] ;

                     ^

/tmp/tmpjcx93_mx/src:26:16: 警告:在算术表达式中使用了函数指针 [-Wpointer-arith]
tap[tap_min] += time[i] ; ~~~~~~~~~~~~^~~~~~~~~
/tmp/tmpjcx93_mx/src:26:16: 错误:invalid conversion from ‘time_t ()(time_t) throw ()’ {aka ‘long int ()(long int)’} to ‘int’ [-fpermissive]


P2772 寻找平面上的极大点

本题成功AC,主体思路是每次找在剩余点中,y最大的点,之后排除掉所有x比他小的点即可。


P1095 守望者的逃离

本题A了8个点,2个点wa了,这种问题如何在做题时发现并解决?

P1970 花匠

感觉思路是对的,样例也过了,可提交上去全wa了

相关文章

  • 2019-08-03 贪心四题

    P1190 接水问题 第一次提交,“不能定义time变量” ;修改变量名后,AC;为什么Dev-C里面没报错呢? ...

  • 程序员进阶之算法练习(二十八)

    前言 四道题,分别锻炼哈希、贪心、贪心+排序、二分四个能力。第一题较为简单,后续的题目都需要一定的基础。贪心是最基...

  • Java 算法 - 跳跃游戏(贪心法和动态规划)

    注意,贪心法是错误的!贪心法在lintCode能够AC,leetCode不能AC。因为这道题是一道最优题,而贪心法...

  • #(ACM)省赛题型总结#

    省赛题型总结: (1)一到二道简单题; (2)贪心:(hh负责拉题,oj,或者hust) 1:基础贪心; 2:区间...

  • 文先森的日常

    日精进打卡第368天 姓名:李文杰 (四爷); 公司:中国太平人寿; 日期:2019-08-03 【知~学习】 《...

  • 38.LeetCode455. 分发饼干

    标签: 贪心 难度: 简单 题目描述 我的解法 此题的贪心策略是: 每次拿最小的饼干给胃口最小的孩子。明确思路...

  • UVa11729-贪心算法

    题目链接:点击这里此题可用简单的贪心算法,具体可见CLRS中的贪心算法介绍。可使用Exchange策略进行证明:当...

  • 2019-08-24LeetCode122. 买卖股票的最佳时机

    主要是想到 C

  • 2019-08-04 总结

    part 1 贪心四题 接水问题 重点:time等可能为关键字的单词最好不用,虽然有时在 c++上能过。 代码 寻...

  • lettcode刷题之贪心

    leetcode刷题,使用python 1, 跳跃游戏 II —— 0045 贪心算法给定一个长度为 n 的 0...

网友评论

      本文标题:2019-08-03 贪心四题

      本文链接:https://www.haomeiwen.com/subject/esdsdctx.html