-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57cd930
commit fa5f361
Showing
6 changed files
with
260 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "bits/stdc++.h" | ||
using namespace std; | ||
|
||
# define s(n) scanf("%d",&n) | ||
# define sc(n) scanf("%c",&n) | ||
# define sl(n) scanf("%lld",&n) | ||
# define sf(n) scanf("%lf",&n) | ||
# define ss(n) scanf("%s",n) | ||
|
||
# define INF (int)1e9 | ||
# define EPS 1e-9 | ||
# define MOD 1000000007 | ||
|
||
|
||
typedef long long ll; | ||
|
||
int main() | ||
{ | ||
int t=1; | ||
// cin >> t; | ||
while(t--){ | ||
int n; | ||
s(n); | ||
ll a[n]; | ||
for(int i=0;i<n;i++) | ||
sl(a[i]); | ||
sort(a,a+n); | ||
ll sum=0; | ||
for(int i=0;i<n-1;i++){ | ||
sum+=a[n-2]-a[i]; | ||
} | ||
printf("%lld\n",sum ); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "bits/stdc++.h" | ||
using namespace std; | ||
|
||
# define s(n) scanf("%d",&n) | ||
# define sc(n) scanf("%c",&n) | ||
# define sl(n) scanf("%lld",&n) | ||
# define sf(n) scanf("%lf",&n) | ||
# define ss(n) scanf("%s",n) | ||
|
||
# define INF (int)1e9 | ||
# define EPS 1e-9 | ||
# define MOD 1000000007 | ||
|
||
|
||
typedef long long ll; | ||
|
||
double dis(double x,double y,double x1,double y1){ | ||
return sqrt(pow((x-x1),2)+pow((y-y1),2)); | ||
} | ||
int main() | ||
{ | ||
int t=1; | ||
while(t--){ | ||
int n,k; | ||
s(n);s(k); | ||
double dist[n]; | ||
double xx,yy; | ||
for(int i=0;i<n;i++){ | ||
sf(xx);sf(yy); | ||
dist[i]=dis(xx,yy,0,0); | ||
} | ||
sort(dist,dist+n); | ||
printf("%lf\n",dist[k-1]); | ||
} | ||
|
||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "bits/stdc++.h" | ||
using namespace std; | ||
|
||
# define s(n) scanf("%d",&n) | ||
# define sc(n) scanf("%c",&n) | ||
# define sl(n) scanf("%lld",&n) | ||
# define sf(n) scanf("%lf",&n) | ||
# define ss(n) scanf("%s",n) | ||
|
||
# define INF (int)1e9 | ||
# define EPS 1e-9 | ||
# define MOD 1000000007 | ||
|
||
|
||
typedef long long ll; | ||
|
||
int main() | ||
{ | ||
int t; | ||
|
||
ll fx,fy; | ||
sl(fx);sl(fy); | ||
cin >> t; | ||
ll sumx=0,sumy=0,x,y; | ||
while(t--){ | ||
sl(x);sl(y); | ||
sumx+=x; | ||
sumy+=y; | ||
} | ||
printf("%lld %lld\n",fx-sumx,fy-sumy); | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include "bits/stdc++.h" | ||
using namespace std; | ||
|
||
# define s(n) scanf("%d",&n) | ||
# define sc(n) scanf("%c",&n) | ||
# define sl(n) scanf("%lld",&n) | ||
# define sf(n) scanf("%lf",&n) | ||
# define ss(n) scanf("%s",n) | ||
|
||
# define INF (int)1e9 | ||
# define EPS 1e-9 | ||
# define MOD 1000000007 | ||
|
||
|
||
typedef long long ll; | ||
typedef struct Map | ||
{ | ||
ll index; | ||
ll pop; | ||
}Map; | ||
bool ComparePop (const Map& l, const Map& r) | ||
{ | ||
return l.pop > r.pop; | ||
} | ||
|
||
|
||
int main() | ||
{ | ||
ll n,m; | ||
sl(n);sl(m); | ||
Map v[m]; | ||
for(int i=0;i<m;i++){ | ||
sl(v[i].index);sl(v[i].pop); | ||
} | ||
sort(v,v+m,&ComparePop); | ||
/*for(int i=0;i<m;i++){ | ||
printf("%lld %lld\n",v[i].index,v[i].pop); | ||
}*/ | ||
ll sum=0,ans=0; | ||
for(int i=0;i<m;i++){ | ||
if(sum+v[i].index<n){ | ||
sum+=v[i].index; | ||
ans+=v[i].index*v[i].pop; | ||
} | ||
else if(sum+v[i].index==n){ | ||
sum+=v[i].index; | ||
ans+=v[i].index*v[i].pop; | ||
break; | ||
} | ||
else if(sum+v[i].index>n){ | ||
ans+=v[i].pop*(n-sum); | ||
sum+=n-sum; | ||
} | ||
if(sum==n) | ||
break; | ||
|
||
} | ||
printf("%lld\n",ans); | ||
|
||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#include "bits/stdc++.h" | ||
using namespace std; | ||
|
||
# define s(n) scanf("%d",&n) | ||
# define sc(n) scanf("%c",&n) | ||
# define sl(n) scanf("%lld",&n) | ||
# define sf(n) scanf("%lf",&n) | ||
# define ss(n) scanf("%s",n) | ||
|
||
# define INF (int)1e9 | ||
# define EPS 1e-9 | ||
# define MOD 1000000007 | ||
|
||
|
||
typedef long long ll; | ||
|
||
int main() | ||
{ | ||
int t; | ||
cin >> t; | ||
while(t--){ | ||
int n,e; | ||
s(n);s(e); | ||
int b[e]; | ||
for(int i=0;i<e;i++){ | ||
s(b[i]); | ||
} | ||
|
||
} | ||
|
||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#include "bits/stdc++.h" | ||
using namespace std; | ||
|
||
# define s(n) scanf("%d",&n) | ||
# define sc(n) scanf("%c",&n) | ||
# define sl(n) scanf("%lld",&n) | ||
# define sf(n) scanf("%lf",&n) | ||
# define ss(n) scanf("%s",n) | ||
|
||
# define INF (int)1e9 | ||
# define EPS 1e-9 | ||
# define MOD 1000000007 | ||
|
||
|
||
typedef long long ll; | ||
vector<int> v[20000]; | ||
|
||
void calc_path(int a,vector<int> path){ | ||
if(v[a].size()==0) | ||
return ; | ||
else{ | ||
for(int i=0;i<v[a].size();i++){ | ||
|
||
} | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
int t; | ||
cin >> t; | ||
while(t--){ | ||
int n,m,j,k,x,y; | ||
s(n);s(m); | ||
|
||
int a[m]; | ||
for(int i=1;i<n+1;i++){ | ||
s(j); | ||
for(int k=0;k<j;k++){ | ||
s(x); | ||
v[i].push_back(x); | ||
} | ||
sort(v[i].begin(), v[i].end(), greater<int>()); | ||
} | ||
for(int k=0;k<m;k++) | ||
s(a[k]); | ||
sort(a,a+m); | ||
vector<int> path[m]; | ||
for(int i=0;i<m;i++){ | ||
calc_path(a[i],path[i]); | ||
} | ||
|
||
|
||
} | ||
|
||
return 0; | ||
} | ||
|