Submission #717735

# Submission time Handle Problem Language Result Execution time Memory
717735 2023-04-02T11:51:01 Z AndrijaM Poi (IOI09_poi) C++14
60 / 100
549 ms 32560 KB
#include <bits/stdc++.h>

using namespace std;

int main()
{
    long long n,t,p;
    cin>>n>>t>>p;
    long long cpt[t]={0};
    vector<long long>v[n];
    long long val[n];
    memset(val,0,sizeof val);
    vector<pair<long long,long long>>r;
    for(long long i=0;i<n;i++)
    {
        for(long long j=0;j<t;j++)
        {
            long long num;
            cin>>num;
            v[i].push_back(num);
            cpt[j]+=num;///lugje-cpt[j] treba
        }
    }
    for(long long i=0;i<n;i++)
    {
        for(long long j=0;j<t;j++)
        {
            if(v[i][j]==1)
            val[i]+=n-cpt[j];
        }
        r.push_back({val[i],i+1});
    }
    sort(r.rbegin(),r.rend());
    vector<pair<long long,long long>>ans;
    bool ok=true;
    long long pos;
    for(long long i=0;i<r.size();i++)
    {
        if(r[i].first==val[p-1])
        {
            ans.push_back({r[i].first, r[i].second});
            if(ok)
            {
                pos=i+1;
                ok=false;
            }
        }
    }
    sort(ans.begin(),ans.end());
    for(long long i=0;i<ans.size();i++)
    {
        if(ans[i].second==p-1)
        {
            pos+=i+1;
        }
    }
    cout<<val[p-1]<<" "<<pos<<endl;
    return 0;
}

Compilation message

poi.cpp: In function 'int main()':
poi.cpp:37:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(long long i=0;i<r.size();i++)
      |                       ~^~~~~~~~~
poi.cpp:50:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |     for(long long i=0;i<ans.size();i++)
      |                       ~^~~~~~~~~~~
poi.cpp:54:16: warning: 'pos' may be used uninitialized in this function [-Wmaybe-uninitialized]
   54 |             pos+=i+1;
      |             ~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 0 ms 212 KB Output isn't correct
5 Correct 1 ms 256 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Incorrect 1 ms 340 KB Output isn't correct
8 Correct 1 ms 340 KB Output is correct
9 Incorrect 3 ms 468 KB Output isn't correct
10 Correct 4 ms 596 KB Output is correct
11 Correct 17 ms 1472 KB Output is correct
12 Incorrect 28 ms 2208 KB Output isn't correct
13 Incorrect 87 ms 5832 KB Output isn't correct
14 Incorrect 120 ms 8256 KB Output isn't correct
15 Incorrect 205 ms 17048 KB Output isn't correct
16 Correct 235 ms 18340 KB Output is correct
17 Incorrect 364 ms 24372 KB Output isn't correct
18 Correct 391 ms 27728 KB Output is correct
19 Correct 498 ms 32472 KB Output is correct
20 Correct 549 ms 32560 KB Output is correct