QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#27831#2616. Attack OrderGeothermal#WA 3ms3696kbC++1.2kb2022-04-11 01:11:332022-04-28 12:01:19

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-04-28 12:01:19]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:3696kb
  • [2022-04-11 01:11:33]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b) - 1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a) - 1; i >= 0; i--)

#define sz(x) (int) (x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ub upper_bound
#define lb lower_bound
#define all(x) x.begin(), x.end()

const char nl = '\n';

void solve() {
	int N; cin >> N;
	vpl A(N); F0R(i, N) cin >> A[i].f;
	F0R(i, N) cin >> A[i].s;

	F0R(iter, N-1) {
		sort(all(A));
		ll sum = 0;
		F0R(i, N) {
			sum += A[i].s;
		}
		F0Rd(i, N) {
			int p = 0; if (i == 0) p = 1;
			if (A[i].f + sum - A[i].s <= A[p].f) {
				A.erase(A.begin() + p); goto done;
			}
		}
		cout << "No" << nl; return;
		done:
		;
	}
	cout << "Yes" << nl;
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int T; cin >> T;
	while(T--) {
		solve();
	}

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3696kb

input:

3
2
15 25
10 5
3
7 0
7 3
10 0
3
10 10
20 20
30 30

output:

Yes
Yes
No

result:

ok 3 token(s): yes count is 2, no count is 1

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 3656kb

input:

1000
4
0 1
0 2
2 2
0 0
4
2 2
1 1
1 1
0 0
4
2 1
1 2
1 0
2 1
3
2 1
1 0
1 1
4
2 0
2 2
1 2
1 2
3
1 0
3 0
0 3
4
1 1
1 0
1 2
1 2
2
1 2
3 1
4
1 2
1 0
2 0
0 2
2
3 3
0 2
4
2 0
1 0
2 1
0 1
3
1 1
1 0
0 3
4
1 1
2 1
0 2
1 1
4
1 2
2 2
1 0
2 1
4
0 0
1 0
0 1
0 1
3
0 1
2 3
0 0
3
3 1
3 2
1 1
4
1 0
0 0
1 1
2 1
4
2 1
1...

output:

No
No
No
No
No
No
No
Yes
No
Yes
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
Yes
No
Yes
No
No
Yes
No
No
Yes
Yes
No
No
No
No
No
No
No
No
No
Yes
No
No
No
Yes
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
No
No
No
Yes
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
No
No
N...

result:

wrong answer expected NO, found YES [16th token]