链接:戳这里
input
3 6
50 85 250
10 15 25
output
Radewoosh
input
8 1
10 20 30 40 50 60 70 80
8 10 58 63 71 72 75 76
output
Tie
Note
In the first sample, there are 3 problems. Limak solves them as follows:
Limak spends 10 minutes on the 1-st problem and he gets 50 - c·10 = 50 - 2·10 = 30 points.
Limak spends 15 minutes on the 2-nd problem so he submits it 10 + 15 = 25 minutes after the start of the contest. For the 2-nd problem he gets 85 - 2·25 = 35 points.
He spends 25 minutes on the 3-rd problem so he submits it 10 + 15 + 25 = 50 minutes after the start. For this problem he gets 250 - 2·50 = 150 points.
So, Limak got 30 + 35 + 150 = 215 points.
Radewoosh solves problem in the reversed order:
Radewoosh solves 3-rd problem after 25 minutes so he gets 250 - 2·25 = 200 points.
He spends 15 minutes on the 2-nd problem so he submits it 25 + 15 = 40 minutes after the start. He gets 85 - 2·40 = 5 points for this problem.
He spends 10 minutes on the 1-st problem so he submits it 25 + 15 + 10 = 50 minutes after the start. He gets max(0, 50 - 2·50) = max(0, - 50) = 0 points.
Radewoosh got 200 + 5 + 0 = 205 points in total. Limak has 215 points so Limak wins.
In the second sample, Limak will get 0 points for each problem and Radewoosh will first solve the hardest problem and he will get 250 - 6·25 = 100 points for that. Radewoosh will get 0 points for other two problems but he is the winner anyway.
In the third sample, Limak will get 2 points for the 1-st problem and 2 points for the 2-nd problem. Radewoosh will get 4 points for the 8-th problem. They won't get points for other problems and thus there is a tie because 2 + 2 = 4.
题意:我感觉这道题意还是看hint吧
思路:模拟这个过程就可以了,不知道要不要开long long ,反正开了不吃亏
代码:
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<string> #include<vector> #include <ctime> #include<queue> #include<set> #include<map> #include<stack> #include<iomanip> #include<cmath> #define mst(ss,b) memset((ss),(b),sizeof(ss)) #define maxn 0x3f3f3f3f #define MAX 1000100 ///#pragma comment(linker, "/STACK:102400000,102400000") typedef long long ll; typedef unsigned long long ull; #define INF (1ll<<60)-1 using namespace std; int n,c; int p[55],t[55]; int main(){ scanf("%d%d",&n,&c); for(int i=1;i<=n;i++) scanf("%d",&p[i]); for(int i=1;i<=n;i++) scanf("%d",&t[i]); ll sum1=0,sum2=0,now=0; for(int i=1;i<=n;i++){ now=now+t[i]; sum1+=max((ll)0,p[i]-now*c); } now=0; for(int i=n;i>=1;i--){ now+=t[i]; sum2+=max((ll)0,p[i]-now*c); } ///cout<<sum1<<" "<<sum2<<endl; if(sum1==sum2) cout<<"Tie"<<endl; else if(sum1>sum2) cout<<"Limak"<<endl; else cout<<"Radewoosh"<<endl; return 0; }
output
NO
YES
NO
YES
YES
input
6 3 9
50 20 51 17 99 24
1 3
1 4
1 5
1 2
2 4
2 2
1 1
2 4
2 3
output
NO
YES
NO
YES
Note
In the first sample, Limak has 4 friends who all sleep initially. At first, the system displays nobody because nobody is online. There are the following 8 queries:
"1 3" — Friend 3 becomes online.
"2 4" — We should check if friend 4 is displayed. He isn't even online and thus we print "NO".
"2 3" — We should check if friend 3 is displayed. Right now he is the only friend online and the system displays him. We should print "YES".
"1 1" — Friend 1 becomes online. The system now displays both friend 1 and friend 3.
"1 2" — Friend 2 becomes online. There are 3 friends online now but we were given k = 2 so only two friends can be displayed. Limak has worse relation with friend 1 than with other two online friends (t1 < t2, t3) so friend 1 won't be displayed
"2 1" — Print "NO".
"2 2" — Print "YES".
"2 3" — Print "YES".
题意:给出n,k,q分别表示n个网络点,k为当前在线的网络点的最大个数,q表示q个操作
思路:我们需要模拟整个q的过程,增删询问,显然只需要优先队列+map模拟就好了
代码:
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<string> #include<vector> #include <ctime> #include<queue> #include<set> #include<map> #include<stack> #include<iomanip> #include<cmath> #define mst(ss,b) memset((ss),(b),sizeof(ss)) #define maxn 0x3f3f3f3f #define MAX 1000100 ///#pragma comment(linker, "/STACK:102400000,102400000") typedef long long ll; typedef unsigned long long ull; #define INF (1ll<<60)-1 using namespace std; struct node{ int v,id; node(int v=0,int id=0):v(v),id(id){} bool operator < (const node &a) const{ return v>a.v; } }; priority_queue<node> qu; map<int,int> M; int n,k,q; node a[300010]; int main(){ scanf("%d%d%d",&n,&k,&q); for(int i=1;i<=n;i++) { scanf("%d",&a[i].v); a[i].id=i; M[a[i].v]=0; } while(q--){ int x,y; scanf("%d%d",&x,&y); if(x==1) { qu.push(node(a[y].v,y)); M[a[y].v]=1; while(qu.size()>k) { node now=qu.top(); qu.pop(); M[now.v]=0; } } else { if(M[a[y].v]==0) cout<<"NO"<<endl; else cout<<"YES"<<endl; } } return 0; }