Submission #6836960


Source Code Expand

Copy
#include <bits/stdc++.h>

using namespace std ;

#define sz(v) (int)v.size()
#define ll long long
#define all(v)  v.begin() , v.end()
#define rall(v)  v.rbegin() , v.rend()
#define pf push_front
#define pb push_back
#define fast FastInputOutput() ;
#define Clear( container , value ) memset( container , value , sizeof container )
#define PI acos( -1.0 )
#define forn( t , v , be , n ) for( t v = be ; v < n ; v++ )
#define fore( x , j ) for( auto x : j )
#define se second
#define fr first
//#define c_b fflush(stdin);
#define debug(x , y) cerr << #x << " = " << x << y ;

const ll Long_max = numeric_limits < ll > :: max() ;
const int Int_max = numeric_limits < int > :: max() ;

void File_input( string pathIn ) {
    freopen( pathIn.c_str(), "r", stdin ) ;
}

void File_output( string pathOut ) {
    freopen( pathOut.c_str(), "w", stdout ) ;
}

int msg() {
    srand( time( 0 ) ) ;
    vector < string > st = {
        "Wish everyone high ratings!",
        "Good luck!",
        "Have fun!",
        "Please, read all the problems!",
        "Go Go fight!"
    } ;
    cerr << st[ rand() % sz( st ) ] ;
    return 0 ;
}

void FastInputOutput() {
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

int n , k ;
vector < pair < int , int > > vec ;
bool cmp( pair < int , int > s , pair < int , int > f ){
if( s.second != f.second ) return s.second > f.second ;
return s.first > f.first ;
}

int main(){

 cin >> n >> k ;
 vec.resize( n ) ;
 int cnt = 0 ;
 forn( int , i , 0 , n ){
   cin >> vec[ i ].first >> vec[ i ].second ;
 }

 sort( all( vec ) , cmp ) ;
 ll sum = 0 ;
 fore( i , vec ){
  // cout << i.first << " " << i.second << "\n" ;
   if( cnt + i.first <= k ) sum += i.second , cnt++ ;
 }

 cout << sum ;

 return 0 ;
}

/*
A B C D
try to solve A , B in 30 min as possible
If their is subtask try to solve the second one first if the constraints are only differ
Read all Problem so you could find an ex that you can solve fast
A -- don't write big code focus again
B -- greedy , math , bit mask , tricks , DP
C -- solve A , B first then solve C but fast as possible
greedy
DP
binary search
DFS , BFS , DSU( detect a cycle , make sets )
bit mask
number theory , math
meet in the middle
focus on the problem and constraints.
*/

Submission Info

Submission Time
Task D - Summer Vacation
User mahmoud_acm
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2363 Byte
Status WA
Exec Time 65 ms
Memory 1024 KB

Compile Error

./Main.cpp: In function ‘void File_input(std::string)’:
./Main.cpp:25:43: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
     freopen( pathIn.c_str(), "r", stdin ) ;
                                           ^
./Main.cpp: In function ‘void File_output(std::string)’:
./Main.cpp:29:45: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
     freopen( pathOut.c_str(), "w", stdout ) ;
                                             ^

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 10 ms 384 KB
testcase_02 WA 3 ms 256 KB
testcase_03 WA 50 ms 896 KB
testcase_04 WA 64 ms 1024 KB
testcase_05 WA 64 ms 1024 KB
testcase_06 AC 64 ms 1024 KB
testcase_07 WA 64 ms 1024 KB
testcase_08 WA 17 ms 512 KB
testcase_09 WA 36 ms 768 KB
testcase_10 WA 53 ms 1024 KB
testcase_11 WA 57 ms 896 KB
testcase_12 WA 17 ms 384 KB
testcase_13 WA 64 ms 1024 KB
testcase_14 WA 59 ms 1024 KB
testcase_15 AC 6 ms 256 KB
testcase_16 WA 65 ms 1024 KB
testcase_17 WA 9 ms 384 KB
testcase_18 WA 53 ms 1024 KB