本文整理汇总了C++中multiset::end方法的典型用法代码示例。如果您正苦于以下问题:C++ multiset::end方法的具体用法?C++ multiset::end怎么用?C++ multiset::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类multiset
的用法示例。
在下文中一共展示了multiset::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: earliest
int earliest(int phi, int lambda){
auto it = taken.begin();
auto nit = it;
++nit;
pii pp = make_pair(phi, lambda);
for (itn t = 0; t < T; t++){
while (nit != taken.end() && nit->first <= t)
++it, ++nit;
auto p = dist(pos[t], pp);
int old = it->first;
if (abs(p.first) > d || abs(p.second) > d)
continue;
auto q = it->second;
if (abs(q.first - p.first) > 1ll * w * (t - old))
continue;
if (abs(q.second - p.second) > 1ll * w * (t - old))
continue;
if (nit != taken.end()){
old = nit->first;
q = nit->second;
if (abs(q.first - p.first) > -1ll * w * (t - old))
continue;
if (abs(q.second - p.second) > -1ll * w * (t - old))
continue;
}
return t;
}
return -1;
}
示例2: main
int main()
{
int n,x;
while(scanf("%d%d",&n,&x)+1)
{
st.clear();
for(int i=0; i<n; i++)
{
int x;
scanf("%d",&x);
st.insert(x);
}
for(;;)
{
it=upper_bound(st.begin(),st.end(),x);
if(it!=st.end())
{
x+=2;
st.erase(it);
}
else
break;
}
printf("%d\n",x+st.size());
}
return 0;
}
示例3: dolnasrednia
void dolnasrednia(int srednia)
{
multiset<int> ocenycopy = oceny;
set<int>::iterator itbeg;
itbeg=ocenycopy.begin();
while(itbeg!=ocenycopy.end())
{
if((*itbeg)<=srednia)
{
pair <set<int>::iterator,set<int>::iterator> zasieg;
zasieg=ocenycopy.equal_range(*itbeg);
for(set<int>::iterator it=zasieg.first; *it< *zasieg.second;it++)
{
dolnasr.insert(*it);
ocenycopy.erase(it);
}
int sumael=0;
for(set<int>::iterator it=dolnasr.begin();it!=dolnasr.end();it++)
{
sumael+=(*it);
}
srednia=floor(sumael/dolnasr.size());
itbeg=ocenycopy.begin();
continue;
}
itbeg++;
}
int sumael=0;
for(set<int>::iterator it=dolnasr.begin();it!=dolnasr.end();it++)
{
sumael+=(*it);
}
skroc(sumael, dolnasr.size());
}
示例4: main
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> t;
while(t--){
S.clear();
cin >> n;
for(int i=0;i<n;i++){
cin >> x;
it = S.upper_bound(x);
if(it==S.end()){
S.insert(x);
}
else{
S.erase(it);
S.insert(x);
//(*it) = x;
}
}
cout << S.size() << " ";
for(multiset<int>::iterator it=S.begin();it!=S.end();it++){
cout << (*it) << " ";
}
cout << endl;
}
return 0;
}
示例5: main
int main(){
ll n, res, k, val;
while(true){
scanf("%lld", &n);
if(n == 0)
break;
s.clear();
res = 0;
while(n--){
scanf("%lld", &k);
for(int j = 0; j < k; j++){
scanf("%lld", &val);
s.insert(val);
}
res += *s.begin() - *prev(s.end());
s.erase(s.begin());
s.erase(prev(s.end()));
}
printf("%lld\n", res);
}
return 0;
}
示例6: solve
void solve(){
s(n)
sumSet.clear();
for(int i=0;i<(2<<n-1);++i){
ll x;
sll(x)
sumSet.insert(x);
}
vector<int> arr,ssums;
for(multiset<int>::iterator itr=sumSet.begin();itr!=sumSet.end();itr++){
if(*itr == 0)
continue;
int e=*itr;
int sp=ssums.size();
fr(i,0,sp)
ssums.PB(ssums[i]+e);
for(int i=sp;i<ssums.size();i++){
multiset<int>::iterator tmp=sumSet.find(ssums[i]);
if(tmp!=sumSet.end()) sumSet.erase(tmp);
}
ssums.PB(e);
arr.PB(e);
if(arr.size() == n) break;
}
fr(i,0,arr.size())
printf("%d ",arr[i]);
printf("\n");
}
示例7: main
int main() {
int idx, x;
while(~scanf("%d%d", &n, &m)) {
se.clear();
se2.clear();
mn = INF;
for(int i=1; i<=n; i++) {
scanf("%d", a+i);
se.insert(a[i]);
b[i] = a[i];
}
for(int i=2; i<=n; i++)
se2.insert(myabs(a[i]-a[i-1]));
for(multiset<int>::iterator it = se.begin(); ; ) {
multiset<int>::iterator it2 = it;
it++;
if(it == se.end())
break;
mn = min(mn, myabs((*it) - (*it2)));
}
//show_se();
//cout << "Min: " << mn << endl;
while(m--) {
scanf("%s", com);
if(com[0] == 'I') {
scanf("%d%d", &idx, &x);
multiset<int>::iterator it = se.lower_bound(x);
mn = min(mn, myabs((*it) - x));
if(it!=se.begin()) {
it--;
mn = min(mn, myabs(x - (*it)));
}
se.insert(x);
if(idx!=n) {
it = se2.lower_bound(myabs(b[idx] - a[idx+1]));
//se2.erase(myabs(b[i] - a[i+1]));
se2.erase(it);
se2.insert(myabs(x - a[idx+1]));
}
se2.insert(myabs(b[idx] - x));
b[idx] = x;
//show_se();
} else if(com[1] == 'i') {
printf("%d\n", mn);
} else {
multiset<int>::iterator it = se2.end();
it--;
printf("%d\b", *it);
}
}
}
return 0;
}
示例8: main
int main()
{
//freopen("I.in","r",stdin);
//freopen("I.out","w",stdout);
int T;
scanf("%d", &T);
for(int cas=1;cas<=T;cas++)
{
mst.clear();
int n, m, k, cnt = 0;
long long num;
scanf("%d%d%d", &n, &m, &k);
for(int i = 0; i < n; ++i)
{
scanf("%lld", &num);
if(num <= k)
{
mst.insert(num);
}
}
while(true)
{
int sz = mst.size();
if(sz < 2)
break;
it1 = mst.end();
it1--;
long long fst = *it1;
mst.erase(it1);
it2 = mst.lower_bound(min(fst, k - fst));
if(it2 == mst.end())
it2--;
if(it2 == mst.begin() && *it2 > (k - fst))
continue;
if(*it2 <= k - fst)
{
ans[cnt++] = fst * ( *it2);
mst.erase(it2);
}
else
{
it2 --;
ans[cnt++] = fst * (*it2);
mst.erase(it2);
}
}
sort(ans, ans + cnt, cmp);
long long res = 0;
for(int i = 0; i < min(m, cnt); ++i)
{
res += ans[i];
}
printf("CASE #%d: %lld\n",cas,res);
}
return 0;
}
示例9: add
void add(ll x){
multiset<ll>::iterator it;
multiset<ll>::iterator jt;
if (cnt == 0){
m2.insert(x);
cnt++;
c2++;
printf("%lld\n",x);
return;
}
jt = m2.begin();
if (cnt == 1){
if (x <= *jt){
m1.insert(x);cnt++;c1++;
} else {
m1.insert(*jt);m2.erase(jt);
m2.insert(x);cnt++;c1++;
}
print();
return;
}
it = m1.end(); it--;
if (cnt%2){
if (x <= *it){
m1.insert(x);
c1++;
} else {
m2.insert(x);
c1++;
jt = m2.begin();
m1.insert(*jt);
m2.erase(jt);
}
} else {
if (x >= *jt){
c2++;
m2.insert(x);
} else {
c2++;
m1.insert(x);
it = m1.end(); it--;
m2.insert(*it);
m1.erase(it);
}
}
cnt++;
print();
}
示例10: FindNode
multiset<Node,NodeCompare>::iterator FindNode(const multiset<Node, NodeCompare>& nodes, int i, int j)
{
for (set<Node, NodeCompare>::iterator it = nodes.begin(); it != nodes.end(); ++it)
{
if (it->x == i && it->y == j)
{
return it;
}
}
return nodes.end();
}
示例11: main
int main(){
n=getint();
long long ans=0;
while(n--){
m=getint();
while(m--)S.insert(getint());
ans+=*(--S.end())-*S.begin();
S.erase(--S.end());
S.erase(S.begin());
}cout<<ans<<endl;
return 0;
}
示例12: compare
int compare(multiset<int>& l, multiset<int>& r) {
auto iterl=l.begin(), iterr=r.begin();
while (iterl!=l.end() && iterr!=r.end()) {
if (*iterl<*iterr) return -1;
else if (*iterl>*iterr) return 1;
else {
iterl++;
iterr++;
}
}
if (iterl==l.end() && iterr==r.end()) return 0;
else if (iterl==l.end()) return -1;
else return 1;
}
示例13: main
int main() {
ifstream in; ofstream out;
in.open("input.txt"); out.open("output.txt");
int count=0;
in >> M >> N;
char t;
for(int i=0; i<M; i++){
in >> t;
parolaChars.insert(t);
}
in >> stringa;
for(int i=0; i<M; i++){
it = parolaChars.find (stringa[i]);
if(it!=parolaChars.end())
parolaChars.erase (it);
else
parolaCharsUnused.insert(stringa[i]);
}
if(parolaChars.empty())
count++;
for(int i=M; i<N; i++){
it = parolaCharsUnused.find (stringa[i-M]);
if(it!=parolaCharsUnused.end())
parolaCharsUnused.erase (it);
else
parolaChars.insert(stringa[i-M]);
it = parolaChars.find (stringa[i]);
if(it!=parolaChars.end())
parolaChars.erase (it);
else
parolaCharsUnused.insert(stringa[i]);
//cout << parolaChars.size() << " " << stringa[i-M] << " " << stringa[i] << endl;
if(parolaChars.empty())
count++;
}
out << count;
in.close(); out.close();
return 0;
}
示例14: main
int main(){
#ifndef ONLINE_JUDGE
freopen("in","r",stdin);
#endif
scanf("%d",&n);
int maxScore=0,minScore=2*n;
For(i,n)scanf("%d",&a[i]);
For(i,n)scanf("%d",&b[i]);
sort(b+1,b+n+1);
For(i,n)st.insert(a[i]);
for(int i=n; i; i--){
it=st.upper_bound(b[i]);
if(it!=st.end()){
maxScore+=2;
st.erase(it);
mark[i]=1;
}
}
For(i,n)if(!mark[i]){
it=st.lower_bound(b[i]);
if(it!=st.end()){
maxScore++;
st.erase(it);
}
}
st.clear();
memset(mark,0,sizeof(mark));
sort(a+1,a+n+1);
For(i,n)st.insert(b[i]);
for(int i=n; i; i--){
it=st.upper_bound(a[i]);
if(it!=st.end()){
minScore-=2;
st.erase(it);
mark[i]=1;
}
}
For(i,n)if(!mark[i]){
it=st.lower_bound(a[i]);
if(it!=st.end()){
minScore--;
st.erase(it);
}
}
printf("%d %d\n",maxScore,minScore);
return 0;
}
示例15: delsegment
void delsegment(const int id, const vector<seg> &a)
{
pdd tmpp;
set<seg>::iterator
nxt = next (where[id]),
prv = prev (where[id]);
if (nxt != s.end() && prv != s.end() && abs(nxt->theta-prv->theta) > EPS)
{
tmpp = inspoint(*prv, a[id]);
//debug("pushing1", nxt->id, prv->id, tmpp.first, nxt->p.x, nxt->q.x);
if(inrange(*nxt, *prv, tmpp.first) && tmpp.first > cur_x) e.push(event(tmpp.first, tmpp.second, 0, nxt->id, prv->id));
}
//debug("removing", id);
s.erase (where[id]);
}