QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#90467#5252. Deforestationysghwzp#Compile Error//C++14730b2023-03-23 11:22:032023-03-23 11:22:04

Judging History

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

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

answer

#include <bits/stdc++.h>

using i64 = long long;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);

	int W;
	std::cin >> W;

	std::function<std::pair<i64, int>()> dfs = [&]() -> std::pair<i64, int> {
		int M, N;
		std::cin >> M >> N;

		std::vector<int> a(N);
		i64 sum = 0;
		for (int i = 0; i < N; i++) {
			auto [ans, l] = dfs();
			sum += ans;
			sum += l / W;
			l %= W;
			a[i] = l;
		}

		std::sort(a.begin(), a.end());
		int l = 0;
		int i = 0;
		while (i < N && l + a[i] <= W) {
			l += a[i];
			i += 1;
		}
		sum += N - i;
		l += M;
		return std::pair(sum, l);
	};

	auto [ans, l] = dfs();
	ans += (l + W - 1) / W;
	std::cout << ans << "\n";

	return 0;
}

詳細信息

answer.code: In lambda function:
answer.code:19:30: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’
   19 |                         auto [ans, l] = dfs();
      |                              ^
answer.code:35:33: error: missing template arguments before ‘(’ token
   35 |                 return std::pair(sum, l);
      |                                 ^
answer.code: In function ‘int main()’:
answer.code:38:14: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’
   38 |         auto [ans, l] = dfs();
      |              ^