QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#61804#2541. Coins and BoxesFamiglistmoCompile Error//C++141.0kb2022-11-14 21:48:082022-11-14 21:48:10

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-11-14 21:48:10]
  • 评测
  • [2022-11-14 21:48:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

char buf[1 << 23], *p1 = buf, *p2 = buf;
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1 ++)
int read() {
    int s = 0, w = 1; char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') w = -1; ch = getchar(); }
    while(isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
    return s * w;
}

int a[N], b[N];

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n; cin >> n;
	for (re int i = 1; i <= n; ++i) cin >> a[i];
	for (Re int i = 1; i <= n; ++i) cin >> b[i];

	const int mx = max(b[n], a[n]);
	i64 ans = 1e15, now = 0;
	int j = 1, las = 0;
	for (re int i = 1; i <= n; ++i)
	{
		while (j <= n && b[j] <= a[i])
		{
			if (i > j) now += 3 * (b[j] - las);
			else now += b[j] - las;
			las = b[j], ++j;
		}
		if (i > j) now += 3 * (a[i] - las);
		else now += a[i] - las;
		ans = min(ans, now + (mx - a[i] << 1));
		las = a[i];
	}

	cout << ans << '\n';
	
	return 0;
}

Details

answer.code:13:7: error: ‘N’ was not declared in this scope
   13 | int a[N], b[N];
      |       ^
answer.code:13:13: error: ‘N’ was not declared in this scope
   13 | int a[N], b[N];
      |             ^
answer.code: In function ‘int main()’:
answer.code:21:14: error: ‘re’ was not declared in this scope
   21 |         for (re int i = 1; i <= n; ++i) cin >> a[i];
      |              ^~
answer.code:21:28: error: ‘i’ was not declared in this scope
   21 |         for (re int i = 1; i <= n; ++i) cin >> a[i];
      |                            ^
answer.code:21:48: error: ‘a’ was not declared in this scope
   21 |         for (re int i = 1; i <= n; ++i) cin >> a[i];
      |                                                ^
answer.code:22:14: error: ‘Re’ was not declared in this scope
   22 |         for (Re int i = 1; i <= n; ++i) cin >> b[i];
      |              ^~
answer.code:22:28: error: ‘i’ was not declared in this scope
   22 |         for (Re int i = 1; i <= n; ++i) cin >> b[i];
      |                            ^
answer.code:22:48: error: ‘b’ was not declared in this scope
   22 |         for (Re int i = 1; i <= n; ++i) cin >> b[i];
      |                                                ^
answer.code:24:28: error: ‘b’ was not declared in this scope
   24 |         const int mx = max(b[n], a[n]);
      |                            ^
answer.code:24:34: error: ‘a’ was not declared in this scope
   24 |         const int mx = max(b[n], a[n]);
      |                                  ^
answer.code:25:9: error: ‘i64’ was not declared in this scope
   25 |         i64 ans = 1e15, now = 0;
      |         ^~~
answer.code:27:14: error: ‘re’ was not declared in this scope
   27 |         for (re int i = 1; i <= n; ++i)
      |              ^~
answer.code:27:28: error: ‘i’ was not declared in this scope
   27 |         for (re int i = 1; i <= n; ++i)
      |                            ^
answer.code:31:36: error: ‘now’ was not declared in this scope; did you mean ‘pow’?
   31 |                         if (i > j) now += 3 * (b[j] - las);
      |                                    ^~~
      |                                    pow
answer.code:32:30: error: ‘now’ was not declared in this scope; did you mean ‘pow’?
   32 |                         else now += b[j] - las;
      |                              ^~~
      |                              pow
answer.code:35:28: error: ‘now’ was not declared in this scope; did you mean ‘pow’?
   35 |                 if (i > j) now += 3 * (a[i] - las);
      |                            ^~~
      |                            pow
answer.code:36:22: error: ‘now’ was not declared in this scope; did you mean ‘pow’?
   36 |                 else now += a[i] - las;
      |                      ^~~
      |                      pow
answer.code:37:17: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   37 |                 ans = min(ans, now + (mx - a[i] << 1));
      |                 ^~~
      |                 abs
answer.code:37:32: error: ‘now’ was not declared in this scope; did you mean ‘pow’?
   37 |                 ans = min(ans, now + (mx - a[i] << 1));
      |                                ^~~
      |                                pow
answer.code:41:17: error: ‘ans’ was not declared in this scope; did you mean ‘abs’?
   41 |         cout << ans << '\n';
      |                 ^~~
      |                 abs