CodeForces Gym 101669

C

Christmas Tree

待補...

D

Harry Potter and The Vector Spell

 待補...

F

Binary Transformations

待補... 

K

Escape Room

題意:第一行給出了一個數字n,表示序列從1-n,接下來n個數表示從某個數開始的最長上升子序列個數,還原原序列 

分析:思維題,只要用筆多列出幾組數據就能知道,從左向右的第一個1一定是最大的,第二個1是次大的...以此類推...所以我們只需要開一個vector數組記錄它們的位置即可

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e7+5;
const int maxn=1e5+5;
const int mod=1e9+7;
int N;
int a[maxn];
vector<int>vec[maxn];
int ans[maxn];
int main()
{
   	ios::sync_with_stdio(false);
   	cin>>N;
   	for(int i=1;i<=N;i++){
   		cin>>a[i];
   		vec[a[i]].push_back(i);
   	}
   	bool flag=0;
   	int t=N;
   	for(int i=1;i<=N;i++){
   		for(int j=0;j<vec[i].size();j++){
   			if(t==0){
   				flag=1;
   				break;
   			}
   			ans[vec[i][j]]=t;
   			t--;
   		}
   		if(flag)break;
   	}
   	
   	for(int i=1;i<=N;i++){
   		cout<<ans[i]<<' ';
   	}
    return 0;
}

 

G

Robots

簽到題

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e7+5;
const int maxn=1e5+5;
const int mod=1e9+7;
struct Node{
	double a,t;
}p[maxn];
int N;
bool cmp(Node x,Node y){
	return x.a>y.a;
}
int main()
{
   	ios::sync_with_stdio(false);
   	cin>>N;
   	for(int i=1;i<=N;i++){
   		cin>>p[i].a>>p[i].t;
   	}
   	double x1=0;
   	double v=0;
   	double v0=0;
   	for(int i=1;i<=N;i++){
   		x1+=v0*p[i].t+(0.5)*p[i].a*p[i].t*p[i].t;
   		v=v0+p[i].a*p[i].t;
   		v0=v;
   	}
   	
   	sort(p+1,p+1+N,cmp);
   	
   	double x2=0;
   	v=0;v0=0;
   	for(int i=1;i<=N;i++){
   		x2+=v0*p[i].t+(0.5)*p[i].a*p[i].t*p[i].t;
   		v=v0+p[i].a*p[i].t;
   		v0=v;
   	}
 //  	cout<<x2<<endl;
   	printf("%.1f\n",abs(x1-x2));
    return 0;
}
J

Cunning Friends

待補... 

 

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章