Submission #90729

#TimeUsernameProblemLanguageResultExecution timeMemory
90729Aydarov03Schools (IZhO13_school)C++14
0 / 100
2 ms828 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() { freopen("school.in" , "r" , stdin ); freopen("school.out" , "w" , stdout ); 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; // system("cls"); 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] ); system("cls"); 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()
      ^
school.cpp: In function 'int main()':
school.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("school.in" , "r" , stdin );
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
school.cpp:23:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
     freopen("school.out" , "w" , stdout );
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
school.cpp:43:11: warning: ignoring return value of 'int system(const char*)', declared with attribute warn_unused_result [-Wunused-result]
     system("cls");
     ~~~~~~^~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...