The third day of labor union

I'm dead

I am a trash

I am a toilet cleaner

I didn’t know why I couldn’t fall asleep last night. I glanced at the watch on my bedside roommate’s mobile phone. It was already half past one, but this morning I woke up naturally before I woke up, so I went to the boss in the computer room. Helped him on duty before he washed and dressed.
After I went to the computer room, I looked at the final exam score sheet in the computer room. Among them, I was put into the last one in the good class. If neither of us is considered comprehensive, I am only 8 points lower than him, although I must have not played Good, but it is indeed a good class level, so I decided to work hard. If I can fine-tune it next semester, I must give it a try. What's the expression?
So I happily took a morning cultural lesson in the computer room, mainly because I was too cooking, I didn't listen to physics lessons, and writing homework was extremely difficult.
So I started to write pile questions again, but I was a man determined to write all data structures by hand, so I started to learn how to write piles.
Because it was so difficult, I succumbed to big roots and small roots.
In the end, the first two-pronged board titled Supermarket came out , and in the middle it was because of the time when writing piles

priority_queue< int,vector< int >,less< int > > p;//大根堆 
priority_queue< int,vector< int >,greater< int > >q;//小根堆 

I didn't write a space. After reading the book for a long time, I noticed that there was a space.
This also made me more determined to learn handwriting pileInsert picture description here

#include<bits/stdc++.h>
using namespace std;
priority_queue< int,vector< int >,less< int > > p;//大根堆 
priority_queue< int,vector< int >,greater< int > >q;//小根堆 
struct supermaket{
    
    
	int a,b;
}sup[10086];
int n,ans;

bool mycmp(supermaket x,supermaket y)
{
    
    
	return x.b<y.b;
}

int main()
{
    
    
	while(cin>>n)
	{
    
    
		ans=0;
		for(int i=1;i<=n;i++)
			scanf("%d%d",&sup[i].a,&sup[i].b);
		sort(sup+1,sup+n+1,mycmp);
		q.push(sup[1].a);
		for(int i=2;i<=n;i++)
		{
    
    
			if(q.size()<sup[i].b) q.push(sup[i].a);
			else if(sup[i].a>q.top())
			{
    
    
				q.pop();
				q.push(sup[i].a);
			}
		}
		while(!q.empty())
		{
    
    
			ans+=q.top();
			q.pop();
		}
		cout<<ans<<endl;
	}
	return 0;
}

It's ridiculous to pile this stuff! ! !

So angry I wrote a tract largest and subsequence , but I think it should be called and the largest substring, substring impression should be attached to the sub-sequence is not required.

#include <bits/stdc++.h>
using namespace std;
const int N=3e5+10;
long long t[N],a[N],sum,n,m,hh,ans=-9999999;
int main()
{
    
    
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++)
	{
    
    
		scanf("%lld",&a[i]);
		a[i]=a[i-1]+a[i];
	}
	for(int i=1;i<=n;i++)
	{
    
    
		if(i-t[hh]>m) hh++;
		ans=max(ans,a[i]-a[t[hh]]);
		while(hh<=sum&&a[t[sum]]>=a[i]) sum--;
		t[++sum]=i;
	}
	cout<<ans;
	return 0;
}

First add the input each time to the previous one to get the sum of the 1st to the i-th number, and then it will be a bit of a typical prefix sum, and then maintain a monotonic queue.
After I finished writing, I was in a good mood, so I started to write about physics, but because I hadn't heard the class and stayed in the computer room for a long time, it took a long time to do less than 2 pages with difficulty. So I took the physics online class of Hyp boss, it's really fragrant! ! !
Insert picture description here

(Invasion)

So I realized it, and after about 1 hour, I started to copy "The Difficulty of Shu Road" to complete the calligraphy homework.
During the meal, I complained about why Xiaonian couldn't go home to sacrifice the stove, which aroused the sympathy of the senior high school seniors.
The new roll of paper issued by the teacher back to the class leader was outrageous. I didn’t even have a position. Of course, I didn’t have one. The key point was that I was watching the video when I went, and the squad leader of Xingxing didn’t let me go to the podium to roll the paper, so I went back. I stood there for 15 minutes, what a fuck! The roll of paper I got at the end was not complete.
Then there was a wave of voluntary labor-cleaning the computer room.
I have to say that my desktop is really messy.
Then I started to learn handwriting pile, but it is said that there are not many people who handwriting pile, and there is not much difference in time complexity and the like for handwriting.

Then I can’t start writing Homer’s epic

If this is to shorten the homework instead of shortening Homer's Epic, I can directly become enthusiastic.
However, the teacher suddenly came to send candy. Since I didn’t buy sesame candy, the teacher gave each person a large handful of Russian purple candy. I was highly autistic and decided to watch the problem solving video. When I didn’t finish watching it, the boss asked me to take the AC Saber, I got the question of finding coins . Seeing that the data range is so small, I decided to set up the bool array, but because I didn't consider that a coin cannot be used twice, the first time was wrong.

#include<bits/stdc++.h>
using namespace std;
int n,m,a;
bool flag[100010];
int main()
{
    
    
    cin>>n>>m;
    for(int i=1;i<=n ;i++)
    {
    
    
        scanf("%d",&a);
        flag[a]=1;
    }
    for(int i=1;i<=m;i++)
    {
    
    
        if((flag[i])&&(flag[m-i])&&((m-i)!=i))
        {
    
    
            cout<<i<<' '<<m-i;
            return 0;
        }
    }
    cout<<"No Solution";
    return 0;
}

Code time: 8 minutes 11.913 seconds. Luckily, the AC dropped before the boss, and I was in a good mood.
In the end, I complained about the newly opened group of the old class. I am the only one at present, and they are not even managed by me.
嘤嘤嘤Insert picture description here

Guess you like

Origin blog.csdn.net/ydsrwex/article/details/113623589