Submission #929109

# Submission time Handle Problem Language Result Execution time Memory
929109 2024-02-17T17:26:58 Z sondos225 Hokej (COCI17_hokej) C++17
72 / 120
141 ms 17360 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define yes "YES"
#define no "NO"
#define bigg INT_MAX
#define debug(x) cout<<(#x)<<" = " <<x<<endl;
#define all(x) x.begin(),x.end()
#define sz size()
#define nn '\n'
#define mms(x,y) memset(x,y,sizeof(x))
#define forr(i,j,n) for (int i=j; i<n; i++)
#define forn(i,j,n) for (int i=j; i>n; i--)
#define fi first
#define se second
#define la "LA"
#define cinn(x,y) for(int i=0; i<y; i++) cin>>x[i];
#define pii pair<int,int>
#define tii tuple<int,int,int>
bool cmp(tii a, tii b)
{
    if (get<0>(a)==get<0>(b)) return get<1>(a)>get<1>(b);
    return get<0>(a)>get<0>(b);
}
bool cp(tii a, tii b)
{
   // if (get<1>(a)==get<1>(b)) return get<0>(a)>get<0>(b);
    return get<0>(a)<get<0>(b);
}
signed main()
{
//    #ifndef LOCAL
//    freopen("helpcross.in","r",stdin);
//    freopen("helpcross.out","w", stdout);
//    #endif
    fast
    int m,n;
    cin>>m >>n;
    tii a[n];
    forr(i,0,n)
    {
        cin>>get<0>(a[i]) >>get<1>(a[i]);
        get<2>(a[i])=i+1;
    }
    sort(a,a+n,cmp);
    int tt=m*6;
    int sm=0;
    vector<tii> b;
    int ans=0;
    forr(i,0,n)
    {
        sm+=(get<1>(a[i]));
        b.pb(a[i]);
        if (sm>=tt)
        {
            int x=sm-(get<1>(a[i]));
            x=tt-x;
            ans+=(get<0>(a[i])*x);
            break;
        }
        ans+=(get<0>(a[i])*get<1>(a[i]));
    }
  //  sort(all(b),cp);
    int cr=1;
    int tim=0;
    bool f=0;
    int team[7]={ };
    vector<tii> v;
    forr(i,0,b.sz)
    {
        int q=get<0>(b[i]), t=get<1>(b[i]), x=get<2>(b[i]);
        if (f==0)
        {
            team[cr]=x;
           // cr++;
            tim+=t;
        }
        else
        {
            get<2>(v.back())=x;
            //cout<<x<<nn;
            tim+=t;
            f=0;
        }
        if (tim==m) { f=0;
            cr++;
           tim=0;}
        else if (tim>m)
        {
           // f=0;
            cr++;
          // tim=0;
            //ybd2
            tim-=m;
            if (cr<=6) {team[cr]=x;
            v.pb({tim,x,0});}
            //cout<<tim<<' '<<x<<' ';
            f=1;
        }
        else
        {
            v.pb({tim,x,0});
            //cout<<tim<<' '<<x<<' ';
            f=1;
        }
    }
    cout<<ans<<nn;
    forr(i,1,7) cout<<team[i]<<' ';
    cout<<nn;
    cout<<v.sz<<nn;
    if (v.sz>(3*n)) n/=0;
    sort(all(v),cp);
    forr(i,0,v.sz)
    {
        cout<<get<0>(v[i])<<' '<<get<1>(v[i])<<' '<<get<2>(v[i])<<nn;
        if (get<1>(v[i])==get<2>(v[i])) n/=0;
    }
    return 0;
}

Compilation message

hokej.cpp: In function 'int main()':
hokej.cpp:14:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::tuple<long long int, long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 | #define forr(i,j,n) for (int i=j; i<n; i++)
      |                                    ^
hokej.cpp:71:5: note: in expansion of macro 'forr'
   71 |     forr(i,0,b.sz)
      |     ^~~~
hokej.cpp:73:13: warning: unused variable 'q' [-Wunused-variable]
   73 |         int q=get<0>(b[i]), t=get<1>(b[i]), x=get<2>(b[i]);
      |             ^
hokej.cpp:113:13: warning: comparison of integer expressions of different signedness: 'std::vector<std::tuple<long long int, long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
  113 |     if (v.sz>(3*n)) n/=0;
      |         ~~~~^~~~~~
hokej.cpp:113:22: warning: division by zero [-Wdiv-by-zero]
  113 |     if (v.sz>(3*n)) n/=0;
      |                     ~^~~
hokej.cpp:14:36: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::tuple<long long int, long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 | #define forr(i,j,n) for (int i=j; i<n; i++)
      |                                    ^
hokej.cpp:115:5: note: in expansion of macro 'forr'
  115 |     forr(i,0,v.sz)
      |     ^~~~
hokej.cpp:118:42: warning: division by zero [-Wdiv-by-zero]
  118 |         if (get<1>(v[i])==get<2>(v[i])) n/=0;
      |                                         ~^~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 6 ms 1332 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 4 ms 772 KB Output is correct
6 Correct 1 ms 604 KB Output is correct
7 Incorrect 4 ms 608 KB Output isn't correct
8 Incorrect 29 ms 4000 KB Output isn't correct
9 Incorrect 138 ms 17288 KB Output isn't correct
10 Incorrect 141 ms 17360 KB Output isn't correct