답안 #1059037

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1059037 2024-08-14T16:19:53 Z MuhammadSaram 팀들 (IOI15_teams) C++17
0 / 100
726 ms 22952 KB
#include <bits/stdc++.h>
#include "teams.h"
 
using namespace std;
 
const int M = 1e5 + 1;
 
#define all(v) v.begin(), v.end()
 
int n,pre[M];
vector<int> V,seg[M*2];
 
void make(int v=1,int s=0,int e=n)
{
	for (int i=s;i<e;i++)
		seg[v].push_back(V[i]);
	sort(all(seg[v]));
	if (s+1==e)
		return;
	int mid=(s+e)/2,lc=v+1,rc=v+(mid-s)*2;
	make(lc,s,mid);
	make(rc,mid,e);
}
 
int get(int l,int r,int x,int v=1,int s=0,int e=n)
{
	if (l>=e or r<=s)
		return 0;
	if (l<=s && e<=r)
	{
		int y=upper_bound(all(seg[v]),x)-begin(seg[v]);
		return y;
	}
	int mid=(s+e)/2,lc=v+1,rc=v+(mid-s)*2;
	return get(l,r,x,lc,s,mid)+get(l,r,x,rc,mid,e);
}
 
void init(int N,int A[],int B[])
{
	n=N;
	vector<pair<int,int>> v1;
	for (int i=0;i<n;i++)
		v1.push_back({B[i],A[i]}),pre[B[i]]++;
	sort(v1.begin(),v1.end());
	for (auto i:v1)
		V.push_back(i.second);
	for (int i=1;i<M;i++)
		pre[i]+=pre[i-1];
	make();
}
 
int can(int m,int k[])
{
	map<int,int> cnt;
	for (int i=0;i<m;i++)
		cnt[k[i]]++;
	vector<pair<int,int>> v;
	for (auto i:cnt)
		v.push_back(i);
	m=v.size();
	int val=0;
	for (int i=0;i<m;i++)
	{
		int s=pre[v[i].first-1],e=n+1;
		while (s+1<e)
		{
			int mid=(s+e)/2;
			if (get(pre[v[i].first-1],mid,v[i].first)>=val+v[i].first*v[i].second)
				e=mid;
			else
				s=mid;
		}
		if (e==n+1)
			return 0;
		if (i!=m-1)
			val=get(pre[v[i+1].first-1],e,v[i].first);
	}
	return 1;
}

Compilation message

teams.cpp: In function 'int get(int, int, int, int, int, int)':
teams.cpp:31:35: warning: conversion from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'} to 'int' may change value [-Wconversion]
   31 |   int y=upper_bound(all(seg[v]),x)-begin(seg[v]);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
teams.cpp: In function 'int can(int, int*)':
teams.cpp:60:10: warning: conversion from 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} to 'int' may change value [-Wconversion]
   60 |  m=v.size();
      |    ~~~~~~^~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5468 KB Output is correct
2 Correct 1 ms 5468 KB Output is correct
3 Correct 1 ms 5468 KB Output is correct
4 Correct 1 ms 5468 KB Output is correct
5 Correct 1 ms 5468 KB Output is correct
6 Correct 1 ms 5468 KB Output is correct
7 Correct 1 ms 5468 KB Output is correct
8 Correct 1 ms 5468 KB Output is correct
9 Incorrect 1 ms 5468 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 20444 KB Output is correct
2 Correct 72 ms 20424 KB Output is correct
3 Correct 71 ms 20492 KB Output is correct
4 Correct 72 ms 20428 KB Output is correct
5 Correct 35 ms 20432 KB Output is correct
6 Correct 34 ms 20432 KB Output is correct
7 Incorrect 36 ms 20636 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 20416 KB Output is correct
2 Correct 84 ms 20428 KB Output is correct
3 Correct 726 ms 22952 KB Output is correct
4 Correct 77 ms 20576 KB Output is correct
5 Correct 347 ms 20440 KB Output is correct
6 Correct 324 ms 20412 KB Output is correct
7 Incorrect 393 ms 20420 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 26 ms 18000 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -