QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#185955#5475. Make a LoopluanmengleiWA 13ms19088kbC++17777b2023-09-22 21:35:142023-09-22 21:35:15

Judging History

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

  • [2023-09-22 21:35:15]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:19088kb
  • [2023-09-22 21:35:14]
  • 提交

answer

#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a, I = b; i <= I; ++i)
#define per(i, a, b) for (int i = a, I = b; i >= I; --i)
using namespace std;

const int N = 1000005;
int f[2][N], g[2][N];

void add(int &x, int y) { x = min(3, x + y); }

int main() {
	ios::sync_with_stdio(0), cin.tie(0);

    int n; cin >> n;

    int sum = 0;
    f[0][0] = 1;
    rep(i, 0, n - 1) {
        int x; cin >> x;
        memcpy(g, f, sizeof g);
        rep(o, 0, 1) {
            rep(s, 0, sum) {
                add(g[!o][s + x], f[o][s]);
            }
        }
        sum += x;
        memcpy(f, g, sizeof f);
    }

    if (sum % 2 || f[0][sum / 2] < 2) {
        cout << "No\n";
    } else {
        cout << "Yes\n";
    }

	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 9ms
memory: 19008kb

input:

4
1 1 1 1

output:

Yes

result:

ok single line: 'Yes'

Test #2:

score: 0
Accepted
time: 13ms
memory: 19052kb

input:

6
1 3 1 3 1 3

output:

Yes

result:

ok single line: 'Yes'

Test #3:

score: -100
Wrong Answer
time: 12ms
memory: 19088kb

input:

6
2 2 1 1 1 1

output:

Yes

result:

wrong answer 1st lines differ - expected: 'No', found: 'Yes'