The 2025 ICPC 德国 German Collegiate Programming Contest——L. Labour Laws · znzryb
## 题目大意
**题目描述**
根据德国《工作时间法》(ArbZG),员工的工作与休息时间需遵守以下规定:
1. 如果单日实际工作时间超过 6 小时,必须至少休息 30 分钟。
1. 如果单日实际工作时间超过 9 小时,必须至少休息 45 分钟。
1. 单日工作时间严禁超过 10 小时。
定义“在岗总时间”为:
$$
在岗总时间 = 实际工作时间 + 休息时间
$$
给定一名员工当天的在岗总时间 $t$(分钟),因为忘记了具体的打卡记录,为了确保不违反法律,请计算该员工为了使工作时间合法,其中最少必须包含多少分钟的休息时间。
**输入格式**
包含一行一个整数 $t$ ($0 \le t \le 1440$),表示当天的在岗总时间(分钟)。
**输出格式**
输出一个非负整数,表示使该工作时长合法的最小休息时间(分钟)。
**样例解释**
- **样例 1**
输入:495
输出:30
解释:总时间 495 分钟。如果休息 30 分钟,实际工作时间为 $495 - 30 = 465$ 分钟(7 小时 45 分)。因为 $465 > 360$(6 小时),法律要求至少休息 30 分钟。当前休息时间 30 分钟满足要求。
- **样例 2**
输入:360
输出:0
解释:总时间 360 分钟。如果休息 0 分钟,实际工作时间为 360 分钟(6 小时)。未超过 6 小时,法律不强制要求休息。
- **样例 3**
输入:540
输出:30
解释:总时间 540 分钟。如果休息 0 分钟,实际工作 $540 > 360$,违规。如果休息 30 分钟,实际工作 $510$ 分钟(8.5 小时),超过 6 小时但不超过 9 小时,需休息 30 分钟,满足要求。
- **样例 4**
输入:0
输出:0
解释:没上班,不需要休息。
## 思路讲解
之所以这道题目它有点阴啊,就是因为它计算的是这个实际工作时间,然后它会有一些空隙。
我们这个 min max 指的是什么呢?就是要么把工作时间降到360分钟以下,接受0小时休息,要么把工作时间降到540分钟以下接受30分钟休息,要么把工作时间降到600分钟以下,结束45分钟休息。
```cpp
void Solve() {
ll N;
cin >> N;
cout << min({max(0ll, N - 360), max(30ll, N - 540), max(45ll, N - 600)}) << "\n";
}
```
## AC代码
AC
[https://qoj.ac/submission/2026351](https://qoj.ac/submission/2026351)
::: 源代码
```cpp
/**
* Problem: Labour Laws
* Contest: QOJ
* Judge: Virtual Judge
* URL: https://vjudge.net/problem/QOJ-14571
* Created: 2026-02-11 12:25:54
* Author: Gospel_rock
*
* Powered by AutoCp https://github.com/Pushpavel/AutoCp
*/
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
#define lson(o) (o<<1)
#define rson(o) (o<<1|1)
#define SZ(a) ((long long) a.size())
#define debug(var) cerr << #var <<" = ["<<var<<"]"<<"\n";
#define debug1d(a) \
cerr << #a << " = ["; \
for (int i = 0; i < (int)(a).size(); i++) \
cerr << (i ? ", " : "") << a[i]; \
cerr << "]\n";
#define debug2d(a) \
cerr << #a << " = [\n"; \
for (int i = 0; i < (int)(a).size(); i++) \
{ \
cerr << " ["; \
for (int j = 0; j < (int)(a[i]).size(); j++) \
cerr << (j ? ", " : "") << a[i][j]; \
cerr << "]\n"; \
} \
cerr << "]\n";
#define debug3d(a) \
cerr << #a << " = [\n"; \
for (int i = 0; i < (int)(a).size(); i++) \
{ \
cerr << " [\n"; \
for (int j = 0; j < (int)(a[i]).size(); j++) \
{ \
cerr << " ["; \
for (int k = 0; k < (int)(a[i][j]).size(); k++) \
cerr << (k ? ", " : "") << a[i][j][k]; \
cerr << "]\n"; \
} \
cerr << " ]\n"; \
} \
cerr << "]\n";
#define cend cerr<<"\n-----------\n"
#define fsp(x) fixed<<setprecision(x)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using DB = double;
// using i128 = __int128;
using CD = complex<double>;
static constexpr ll MAXN = (ll)1e6+10, INF = (1ll<<61)-1;
static constexpr ll mod = 998244353; // (ll)1e9+7;
static constexpr double eps = 1e-8;
const double pi = acos(-1.0);
ll lT,testcase;
/*
*
*/
void Solve() {
ll N;
cin >> N;
cout << min({max(0ll, N - 360), max(30ll, N - 540), max(45ll, N - 600)}) << "\n";
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
#ifdef LOCAL
cout.setf(ios::unitbuf); // 无缓冲流,方便我们调试
#endif
// cin >> lT;
// for (testcase=1;testcase<=lT;++testcase)
Solve();
return 0;
}
/*
AC
https://qoj.ac/submission/2026351
*/
```
:::
## 心路历程(WA,TLE,MLE……)