把c++程序翻译成pascal程序
#include<cstdio>#include<algorithm>#include<queue>usingnamespacestd;#defineinf1000000...
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
#define inf 1000000000
#define maxn 200000
#define REP(i,n) for (int i=1;i<=n;++i)
#define REPD(i,n) for (int i=1;i>=1;--i)
priority_queue<int,vector<int> > s;
struct Node{
int x,y;
}a[maxn];
int n,k,t;
long long ans;
bool cmp(Node a,Node b)
{
return (a.x<b.x||(a.x==b.x &&a.y<b.y));
}
int main()
{
scanf("%d",&n);
REP(i,n)scanf("%d%d",&a[i].x,&a[i].y);
sort(a+1,a+n+1,cmp);
t=inf;k=n;
while(t)
{
while (s.size()>0 && t>a[k].x)
{
ans+=s.top();s.pop();
t--;
}
t=a[k].x;
while (k && t==a[k].x){ s.push(a[k].y);k--;}
}
printf("%lld\n",ans);
return 0;
} 展开
#include<algorithm>
#include<queue>
using namespace std;
#define inf 1000000000
#define maxn 200000
#define REP(i,n) for (int i=1;i<=n;++i)
#define REPD(i,n) for (int i=1;i>=1;--i)
priority_queue<int,vector<int> > s;
struct Node{
int x,y;
}a[maxn];
int n,k,t;
long long ans;
bool cmp(Node a,Node b)
{
return (a.x<b.x||(a.x==b.x &&a.y<b.y));
}
int main()
{
scanf("%d",&n);
REP(i,n)scanf("%d%d",&a[i].x,&a[i].y);
sort(a+1,a+n+1,cmp);
t=inf;k=n;
while(t)
{
while (s.size()>0 && t>a[k].x)
{
ans+=s.top();s.pop();
t--;
}
t=a[k].x;
while (k && t==a[k].x){ s.push(a[k].y);k--;}
}
printf("%lld\n",ans);
return 0;
} 展开
3个回答
展开全部
program wapiknow;var n,i,j,k,x,s:longint; a:array [0..10000] of char; c:char;begin read(n); for i:=0 to n-1 do a[i]:='?'; read(k); x:=0; while (k>0) do begin read(s,c); while (s>0) do begin inc(x); if (x=n) then x:=0; dec(s); end; if (a[x]<>'?')and(a[x]<>c) then begin writeln('!'); halt; end; a[x]:=c; dec(k); end; for i:=0 to n-1 do for j:=i+1 to n-1 do if (a[i]=a[j])and(a[i]<>'?') then begin writeln('!'); halt; end; for i:=0 to n-1 do begin write(a[x]); dec(x); if (x=-1) then x:=n-1; end; writeln;end.希望我的回答能帮到你
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询