Submission #6829804


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define M int(1e9+7)


using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;

bool cmp(pair<int, int> p1, pair<int, int> p2) {
    if(p1.first > p2.first)
        return true;
    if(p1.first < p2.first)
        return false;
    return p1.second >= p2.second;
}

int main(){
	fast_io; cout_precision;
	int n;	cin >> n;	int m;	cin >> m;
	vector <pair<int,int> > v;	for(int i=0; i<n; i++){
		int a,b;	cin >> a >> b;	v.pb({b,a});
	}	
	umap <int,int> mp;
	sort(v.begin() , v.end() , cmp);
//	for(int i=0; i<v.size(); i++)	cout<<v[i].fr<<" "<<v[i].sc<<endl;
	int curr =0; ll prof=0;
	for(int i=0; i<v.size(); i++){
		if(v[i].sc + curr <= m){
			if((mp.find(v[i].fr) == mp.end()) ) {
				prof+=v[i].fr;	curr++; mp[v[i].fr] = v[i].sc;
			}
			else if(((mp.find(v[i].fr) != mp.end() ) && (mp.find(v[i].fr)->sc !=v[i].sc ))){
				prof+=v[i].fr;	curr++; mp[v[i].fr] = v[i].sc;
			}
		}
	}
	cout<<prof;
	
	return 0;
}

Submission Info

Submission Time
Task D - Summer Vacation
User iStillLoveBravo
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1399 Byte
Status WA
Exec Time 36 ms
Memory 1524 KB

Judge Result

Set Name All Sample
Score / Max Score 0 / 400 0 / 0
Status
AC × 5
WA × 16
AC × 3
Set Name Test Cases
All sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14, testcase_15, testcase_16, testcase_17, testcase_18
Sample sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 AC 1 ms 256 KB
sample_02 AC 1 ms 256 KB
sample_03 AC 1 ms 256 KB
testcase_01 WA 6 ms 640 KB
testcase_02 WA 2 ms 384 KB
testcase_03 WA 26 ms 1400 KB
testcase_04 WA 35 ms 1524 KB
testcase_05 WA 35 ms 1524 KB
testcase_06 AC 31 ms 1400 KB
testcase_07 WA 35 ms 1524 KB
testcase_08 WA 11 ms 892 KB
testcase_09 WA 24 ms 1400 KB
testcase_10 WA 35 ms 1524 KB
testcase_11 WA 33 ms 1400 KB
testcase_12 WA 9 ms 640 KB
testcase_13 WA 36 ms 1524 KB
testcase_14 WA 29 ms 1400 KB
testcase_15 AC 3 ms 384 KB
testcase_16 WA 32 ms 1400 KB
testcase_17 WA 6 ms 640 KB
testcase_18 WA 34 ms 1524 KB