QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#623423#8790. First Billionrns_ksr#TL 0ms0kbC++141.6kb2024-10-09 11:53:122024-10-09 11:53:13

Judging History

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

  • [2024-10-09 11:53:13]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:0kb
  • [2024-10-09 11:53:12]
  • 提交

answer

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

typedef long long ll;
typedef __float128 ld;

#define pii pair<int, int>
#define fi first
#define se second
#define VI vector<int>
#define VII vector<vector<int> >

const int N = 500500;
const int inf = 1e9 + 100;
const ll infll = 2e18 + 500;

int a[N], vis[N];

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

    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n / 2; i++) vis[i] = 1;
    int s = 0;
    for (int i = 1; i <= n / 2; i++) s += a[i];
    for (int i = n / 2 + 1; i <= n; i++) s -= a[i];
    int ps = 0;
    while (1) {
    	if (!s) break;
    	ps++;
    	int opt = s, optu = -1, optv = -1;
    	for (int i = 1; i <= n; i++) {
    		int ss = s + a[i] * (vis[i] == 0 ? 2 : -2);
			if (1.0 * abs(ss) < 1.0 * abs(opt) + max(0.0, 1e6 - ps) * 10.0 / rand()) {
				opt = ss, optu = i, optv = -1;
			}
		}
    	for (int i = 1; i <= n; i++) if (vis[i] == 0) for (int j = 1; j <= n; j++) if (vis[j] == 1) {
    		int ss = s + 2 * a[i] - 2 * a[j];
			if (1.0 * abs(ss) < 1.0 * abs(opt) + max(0.0, 1e6 - ps) * 10.0 / rand()) {
				opt = ss, optu = i, optv = j;
			}
    	}
    	if (optu > 0) {
    		s += a[optu] * (vis[optu] == 0 ? 2 : -2);
    		vis[optu] ^= 1;
    	}
    	if (optv > 0) {
    		s += a[optv] * (vis[optv] == 0 ? 2 : -2);
    		vis[optv] ^= 1;
    	}
    }
    vector<int> ans;
    for (int i = 1; i <= n; i++) if (vis[i]) ans.push_back(i);
    cout << ans.size() << ' ';
    for (auto e : ans) {
    	cout << e << ' ';
    }
    cout << '\n';

    return 0;
}

詳細信息

Test #1:

score: 0
Time Limit Exceeded

input:

10
386413329 88494216 245947398 316438989 192751270 204627269 65749456 3938400 150458676 345180997

output:


result: