QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#137681#6343. Bitaro's travelAsymmetry#0 0ms3552kbC++141.5kb2023-08-10 16:34:412024-07-04 01:29:42

Judging History

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

  • [2024-07-04 01:29:42]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3552kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 16:34:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using LL=long long;
#define FOR(i,l,r) for(int i=(l);i<=(r);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define ssize(x) int(x.size())
template<class A,class B>auto&operator<<(ostream&o,pair<A,B>p){return o<<'('<<p.first<<", "<<p.second<<')';}
template<class T>auto operator<<(ostream&o,T x)->decltype(x.end(),o){o<<'{';int i=0;for(auto e:x)o<<(", ")+2*!i++<<e;return o<<'}';}
#ifdef DEBUG
#define debug(x...) cerr<<"["#x"]: ",[](auto...$){((cerr<<$<<"; "),...);}(x),cerr<<'\n'
#else
#define debug(...) {}
#endif

int main() {
	cin.tie(0)->sync_with_stdio(0);
	int n;
	cin >> n;
	vector<int> t(n);
	REP (i, n)
		cin >> t[i];

	auto find_start = [&](int x) {
		int ret = 0;
		REP (i, n)
			if (abs(t[ret] - x) > abs(t[i] - x))
				ret = i;
		return ret;
		/*
		int ind = int(upper_bound(t.begin(), t.end(), x) - t.begin());
		int ret = 0;
		if (ind < n && abs(t[ret] - x) > abs(t[ind] - x))
			ret = ind;
		if (ind && abs(t[ret] - x) >= abs(t[ind - 1] - x))
			ret = ind - 1;
		return ret;
		*/
	};

	const int INF = int(1e9);
	auto dist = [&](int p, int q) {
		if (p < 0 || q < 0 || p >= n || q >= n)
			return INF;
		return abs(t[p] - t[q]);
	};

	int q;
	cin >> q;
	REP (xd, q) {
		int x;
		cin >> x;

		x = find_start(x);
		int lf = x - 1, rg = x + 1;
		LL ans = 0;
		REP (i, n - 1) {
			if (dist(x, lf) <= dist(x, rg)) {
				ans += dist(x, lf);
				x = lf;
				--lf;
			}
			else {
				ans += dist(x, rg);
				x = rg;
				++rg;
			}
		}
		cout << ans << endl;
	}
}


詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3552kb

input:

2000
154914587 154914588 154914591 154914592 154914594 154914596 154914598 154914599 154914601 154914603 154914608 154914610 154914612 154914615 154914618 154914619 154914621 154914622 154914626 154914627 154914631 154914633 154914636 154914638 154914640 154914641 154914642 154914644 154914645 15491...

output:

809906248

result:

wrong answer 1st numbers differ - expected: '809906250', found: '809906248'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Time Limit Exceeded

Test #31:

score: 0
Time Limit Exceeded

input:

200000
9 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181...

output:

200098
200098
200098
346046
200098
269768
313076
200098
366120
200098
200098
348433
200098
200098
200098
332141
311760
200098
200098
366459
200098
221124
225466
313243
322095
200098
281351
200098
257342
200098
200098
200098
316285
200098
394056
200098
200098
357928
200098
357158
200098
368006
326207...

result:


Subtask #4:

score: 0
Skipped

Dependency #1:

0%