Submission #90730

#TimeUsernameProblemLanguageResultExecution timeMemory
90730Aydarov03Schools (IZhO13_school)C++14
0 / 100
223 ms22248 KiB
#include <bits/stdc++.h> #define int long long #define fr first #define sc second using namespace std; const int N = 2e5+10; const int inf = 1e9+7; bool cmp( pair<int,int> a, pair<int,int> b) { a.sc > b.sc; } pair <int,int> a[300005]; vector < pair<int,int> > v1 , v2; main() { int n , m , s , ans = 0; cin >> n >> m >> s; int cnt1 = m , cnt2 = s; for(int i = 1; i <= n; i++) cin >> a[i].fr >> a[i].sc; sort( a + 1 , a + n + 1 ); for(int i = 1; i <= n; i++)v1.push_back( a[i] ); sort( a + 1 , a + n + 1 , &cmp); for(int i = 1; i <= n; i++)v2.push_back( a[i] ); for(int i = 0; i < n; i += 2) { if( cnt1 == 0 ) { while( cnt2-- )ans += v2[i].sc; break; } else if( cnt2 == 0 ) { while( cnt1-- )ans += v1[i].fr; break; } else { ans += max( v1[i].fr + v2[i+1].sc , v1[i+1].fr + v2[i].sc); cnt1-- , cnt2--; } } cout << ans; }

Compilation message (stderr)

school.cpp: In function 'bool cmp(std::pair<long long int, long long int>, std::pair<long long int, long long int>)':
school.cpp:13:10: warning: statement has no effect [-Wunused-value]
     a.sc > b.sc;
          ^
school.cpp:14:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
school.cpp: At global scope:
school.cpp:20:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main()
      ^
#Verdict Execution timeMemoryGrader output
Fetching results...