QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#177032 | #5435. Clamped Sequence | ucup-team963# | Compile Error | / | / | C++14 | 723b | 2023-09-12 14:34:53 | 2023-09-12 14:34:53 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
using namespace std;
typedef long long ll;
ll calc(vector<int> x, int l, int r) {
int n = x.size();
for(int i = 0; i < n; ++ i) {
x[i] = max(x[i], l);
x[i] = min(x[i], r);
}
ll ret = 0;
rep(i,1,n - 1) ret += abs(a[i] - a[i - 1]);
return ret;
}
int main() {
if(fopen("yl.in", "r")) {
freopen("yl.in", "r", stdin);
freopen("yl.out", "w", stdout);
}
int n, d;
cin >> n >> d;
vector<int> a(n);
rep(i,0,n - 1) cin >> a[i];
ll ans = 0x3f3f3f3f3f3f3f3fl;
rep(i,0,n - 1) calc(x, a[i], a[i] + d);
cout << ans << endl;
return 0;
}
詳細信息
answer.code: In function ‘ll calc(std::vector<int>, int, int)’: answer.code:14:31: error: ‘a’ was not declared in this scope 14 | rep(i,1,n - 1) ret += abs(a[i] - a[i - 1]); | ^ answer.code: In function ‘int main()’: answer.code:29:25: error: ‘x’ was not declared in this scope 29 | rep(i,0,n - 1) calc(x, a[i], a[i] + d); | ^ answer.code:20:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 20 | freopen("yl.in", "r", stdin); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~ answer.code:21:16: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 21 | freopen("yl.out", "w", stdout); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~