QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#226371#6632. Minimize MedianxuxubaobaoCompile Error//C++171.3kb2023-10-25 21:38:382023-10-25 21:38:38

Judging History

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

  • [2023-10-25 21:38:38]
  • 评测
  • [2023-10-25 21:38:38]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using PII = pair<int,int>;
using ll = long long;

constexpr int N = 2e6 + 10;

ll w[N];
ll c[N];
ll k[N];
int n, m, k;

bool check(ll u) {
	ll cur = 0;
	if(u == 0) {
		for(int i = 1; i <= n / 2 + 1; i ++) {
			cur += c[w[i] + 1];
		}
	}
	else {
		for(int i = 1; i <= n / 2 + 1; i ++) {
			cur += c[(w[i] + u - 1) / u];
		}
	}
	return cur <= k;
}

void solve() {
	cin >> n >> m >> k;
	for(int i = 1; i <= n; i ++) {
		cin >> w[i];
	}
	for(int i = 1; i <= m; i ++) c[i] = 1 << 29;
	for(int i = 1; i <= m; i ++) {
		cin >> c[i];
	}
	for(int i = 1; i <= m; i ++) {
		for(int j = 1; i * j <= m; j ++) {
			c[i * j] = min(c[i * j], c[i] + c[j]);
		}
	}
	for(int i = m; i >= 1; i --) {
		c[i] = min(c[i], c[i + 1]);
	}
	int j = 1;
	for(int i = m; i >= i; i --) {
		while(i * j <= m) j ++;
		c[m + 1] = min(c[m + 1], c[i] + c[j]);
	}
	for(int i = m; i >= 1; i --) {
		c[i] = min(c[i], c[i + 1]);
	}
	sort(w + 1, w + 1 + n);
	ll l = 0, r = 1ll << 29;
	while(r > l) {
		ll mid = (l + r) >> 1;
		if(check(mid)) {
			r = mid;
		}
		else l = mid + 1;
	}
	cout << l << "\n";
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	t = 1;
	cin >> t;
	while(t --){
		solve();
	}
}

詳細信息

answer.code:12:11: error: conflicting declaration ‘int k’
   12 | int n, m, k;
      |           ^
answer.code:11:4: note: previous declaration as ‘ll k [2000010]’
   11 | ll k[N];
      |    ^
answer.code: In function ‘bool check(ll)’:
answer.code:26:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   26 |         return cur <= k;
      |                ~~~~^~~~
answer.code: In function ‘void solve()’:
answer.code:30:23: error: no match for ‘operator>>’ (operand types are ‘std::basic_istream<char>::__istream_type’ {aka ‘std::basic_istream<char>’} and ‘ll [2000010]’ {aka ‘long long int [2000010]’})
   30 |         cin >> n >> m >> k;
      |         ~~~~~~~~~~~~~ ^~ ~
      |                  |       |
      |                  |       ll [2000010] {aka long long int [2000010]}
      |                  std::basic_istream<char>::__istream_type {aka std::basic_istream<char>}
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:168:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  168 |       operator>>(bool& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:168:7: note:   conversion of argument 1 would be ill-formed:
answer.code:30:26: error: cannot bind non-const lvalue reference of type ‘bool&’ to a value of type ‘ll*’ {aka ‘long long int*’}
   30 |         cin >> n >> m >> k;
      |                          ^
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:172:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match)
  172 |       operator>>(short& __n);
      |       ^~~~~~~~
/usr/include/c++/11/istream:172:7: note:   conversion of argument 1 would be ill-formed:
answer.code:30:26: error: invalid conversion from ‘ll*’ {aka ‘long long int*’} to ‘short int’ [-fpermissive]
   30 |         cin >> n >> m >> k;
      |                          ^
      |                          |
      |                          ll* {aka long long int*}
answer.code:30:26: error: cannot bind rvalue ‘(short int)((ll*)(& k))’ to ‘short int&’
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:175:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_istream<_CharT, _Traits>::__istream_type = std::basic_istream<char>]’ (near match)
  175 |       operator>>(unsigned short& __n)
      |       ^~~~~~~~
/usr/include/c++/11/istream:175:7: note:   conversion of argument 1 would be ill-formed:
answer.code:30:26: error: invalid conversion from ‘ll*’ {aka ‘long long int*’} to ‘short unsigned int’ [-fpermissive]
   30 |         cin >> n >> m >> k;
      |                          ^
      |                          |
      |                          ll* {aka long long int*}
answer.code:30:26: error: cannot bind rvalue ‘(short unsigned int)((ll*)(& k))’ to ‘short unsigned int&’
In file included from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/istream:179:7: note: candidate: ‘std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]’ (near match)
  179 |       operator>>(int& __n);
      |       ^~~~~~~~
/usr/include/c++/11/istream:179:7: note:   conversion of argument 1 would be ill-formed:
answer.code:30:26: error: invalid conversion from ‘ll*’ {aka ‘long long int*’} to ‘int’ [-fpermissive]
   30 |         cin >> n >> m >> k;
      |                          ^
      |                          |
      |                          ll* {aka long long int*}
answer.code:30:26: error: cannot bind rvalue ‘(int)((ll*)(& k))’ to ‘int&’
In file included...