Submission #90729

# Submission time Handle Problem Language Result Execution time Memory
90729 2018-12-24T05:56:47 Z Aydarov03 Schools (IZhO13_school) C++14
0 / 100
2 ms 828 KB
#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

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 time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 2 ms 488 KB Output isn't correct
3 Incorrect 2 ms 488 KB Output isn't correct
4 Incorrect 2 ms 504 KB Output isn't correct
5 Incorrect 2 ms 584 KB Output isn't correct
6 Incorrect 2 ms 596 KB Output isn't correct
7 Incorrect 2 ms 668 KB Output isn't correct
8 Incorrect 2 ms 668 KB Output isn't correct
9 Incorrect 2 ms 772 KB Output isn't correct
10 Incorrect 2 ms 800 KB Output isn't correct
11 Incorrect 2 ms 812 KB Output isn't correct
12 Incorrect 2 ms 812 KB Output isn't correct
13 Incorrect 2 ms 812 KB Output isn't correct
14 Incorrect 2 ms 812 KB Output isn't correct
15 Incorrect 2 ms 812 KB Output isn't correct
16 Incorrect 2 ms 812 KB Output isn't correct
17 Incorrect 2 ms 812 KB Output isn't correct
18 Incorrect 2 ms 812 KB Output isn't correct
19 Incorrect 2 ms 812 KB Output isn't correct
20 Incorrect 2 ms 828 KB Output isn't correct