Submission #98404

# Submission time Handle Problem Language Result Execution time Memory
98404 2019-02-22T20:47:51 Z 0_marchuk Hokej (COCI17_hokej) C++14
72 / 120
507 ms 46216 KB
///-------------------///
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>


///   --Constants--  ///
#define MOD 1000000009
#define INF 2000000000
#define INFLL 9000000000000000000ll


///  --  --  ///
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define elif else if
#define sz(a) ((long long)((a).size()))
#define all(a) (a).begin() , (a).end()

#define fastio ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define what(x)  cout << #x << " is " << x << '\n'

#define int long long
#define left rudenkoandaleksistorenonelove
#define right aleksistorenandrudenkoonelove

using namespace std;

typedef unsigned long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector< pair<int, int> > vpii;

const int MAXN = 500200, MAXM = 200, MAXP=18;

int m, n, p, d;
ll ans;
int dp[6][MAXN], k[6];
vector<vector<int>> vec;
void solve()
{
    int cur = 0;
    for(int i = 0; i<6; i++)
        for(int j = 0; j<m;)
        {
            while(vec[cur][1]==0)
                cur++;
            int dist = min(vec[cur][1], m-j);
            vec[cur][1]-=dist;
            dp[i][j]=vec[cur][2];
            ans+=1ll*vec[cur][0]*dist;
            j+=dist;
        }
    cout << ans << '\n';
    for(int i = 0; i<6; i++)
    {
        k[i]=dp[i][0];
        cout << k[i] << ' ';
    }
    cout << '\n';
    vec.clear();
    for(int j = 1; j<m; j++ )
        for(int i = 5; i>=0; i--)
        {
            if(dp[i][j])
            {
                vec.pb({j, k[i], dp[i][j]});
                k[i]=dp[i][j];
            }
        }
    cout << vec.size() << '\n';
    for(int i = 0; i<vec.size(); i++)
    {
        cout << vec[i][0] << ' ' << vec[i][1] << ' ' << vec[i][2] << '\n';
    }

}


int32_t main()
{
    fastio;
//    ifstream cin("file.in");
//    freopen("file.out", "w", stdout);
//    ofstream cout("file.out");
    cin >> m >> n;
    for(int i = 0; i<n; i++)
    {
        cin >> p >> d;
        vec.pb({p, d, i+1});
    }
    sort(all(vec));
    reverse(all(vec));
    solve();

}

Compilation message

hokej.cpp: In function 'void solve()':
hokej.cpp:74:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i<vec.size(); i++)
                    ~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 4 ms 896 KB Output is correct
3 Correct 22 ms 2360 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 13 ms 5180 KB Output is correct
6 Correct 4 ms 640 KB Output is correct
7 Incorrect 5 ms 1024 KB Output isn't correct
8 Incorrect 69 ms 7204 KB Output isn't correct
9 Incorrect 417 ms 42760 KB Output isn't correct
10 Incorrect 507 ms 46216 KB Output isn't correct