-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
20241012 Create cf1082c_xzx_com.cpp (#7495)
- Loading branch information
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
daily_problems/2024/10/1012/personal_submission/cf1082c_xzx_com.cpp
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> | ||
#define fi first | ||
#define se second | ||
#define lll __int128 | ||
#define int long long | ||
using namespace std; | ||
typedef pair<int,int> PII; | ||
typedef long long ll; | ||
void read(ll &x) | ||
{ | ||
x=0;char ch=getchar();int sign=1; | ||
for(;!isdigit(ch);ch=getchar()) if(ch=='-') sign=-1; | ||
for(;isdigit(ch);ch=getchar()) x=(x<<1)+(x<<3)+ch-48; | ||
x*=sign; | ||
} | ||
void write(ll x) | ||
{ | ||
if(x<0) | ||
{ | ||
putchar('-'); | ||
x=-x; | ||
} | ||
if(x>=10) | ||
write(x/10); | ||
putchar(x%10+48); | ||
} | ||
const int N = 1e5 + 10; | ||
bool cmp(int a,int b){ | ||
return a>b; | ||
} | ||
signed main() { | ||
ios::sync_with_stdio(0); | ||
cin.tie(0); | ||
cout.tie(0); | ||
int t=1; | ||
//cin>>t; | ||
while(t--){ | ||
int n,m;cin>>n>>m; | ||
vector<int>a[N]; | ||
for(int i=1;i<=n;i++){ | ||
int x,y;cin>>x>>y; | ||
a[x].push_back(y); | ||
} | ||
vector<int>ans(n,0); | ||
for(int i=1;i<=m;i++){ | ||
sort(a[i].begin(),a[i].end(),cmp); | ||
int sum=0; | ||
for(int j=0;j<a[i].size();j++){ | ||
sum+=a[i][j]; | ||
if(sum>0)ans[j]+=sum; | ||
} | ||
} | ||
int ans1=0; | ||
for(int i=0;i<ans.size();i++)ans1=max(ans1,ans[i]); | ||
cout<<ans1<<'\n'; | ||
} | ||
return 0; | ||
} |