답안 #98395

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98395 2019-02-22T20:14:03 Z 0_marchuk Hokej (COCI17_hokej) C++14
72 / 120
501 ms 48372 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 = 0; i<6; i++)
        {
            if(dp[i][j])
            {
                vec.pb({j, k[i], dp[i][j]});
                k[i]=dp[i][j];
            }
        }
    cout << vec.size() << '\n';
//    reverse(all(vec));
    for(int i = 0; i<vec.size(); i++)
    {
        cout << vec[i][0] << ' ' << vec[i][1] << ' ' << vec[i][2] << '\n';
    }

}


int32_t main()
{
    fastio;
    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:75:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i<vec.size(); i++)
                    ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 7 ms 896 KB Output is correct
3 Correct 24 ms 2744 KB Output is correct
4 Correct 3 ms 512 KB Output is correct
5 Correct 14 ms 5180 KB Output is correct
6 Correct 4 ms 640 KB Output is correct
7 Incorrect 6 ms 1152 KB Output isn't correct
8 Incorrect 62 ms 8072 KB Output isn't correct
9 Incorrect 501 ms 44584 KB Output isn't correct
10 Incorrect 474 ms 48372 KB Output isn't correct