社区讨论
这题跟差分有什么关系吗
P1672[USACO05FEB] Feed Accounting S参与者 5已保存回复 5
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 5 条
- 当前快照
- 1 份
- 快照标识符
- @m0ch9u90
- 此快照首次捕获于
- 2024/08/27 21:43 2 年前
- 此快照最后确认于
- 2025/11/04 22:14 4 个月前
rt,本来是来练习差分的,结果想了半天也没想出差分,写了个暴力反而还A了。。。
CPP#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const int N = 2e3 + 5;
int c, f1, f2, d;
int tmp[N];
int main()
{
scanf("%d%d%d%d", &c, &f1, &f2, &d);
for (int i = 1; i <= c; i ++ )
{
int a, b;
scanf("%d%d", &a, &b);
for (int j = a; j <= b; j ++ ) tmp[j] ++ ;
}
for (int i = d; i >= 1; i -- )
{
f1 -= tmp[i];
if (f1 == f2)
{
printf("%d\n", i);
return 0;
}
}
return 0;
}
回复
共 5 条回复,欢迎继续交流。
正在加载回复...