답안 #98403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
98403 2019-02-22T20:46:45 Z 0_marchuk Hokej (COCI17_hokej) C++14
0 / 120
586 ms 66560 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 = 6; 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++)
                    ~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 384 KB Integer 0 violates the range [1, 102]
2 Runtime error 7 ms 1640 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 19 ms 4656 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Incorrect 3 ms 512 KB Integer 0 violates the range [1, 500]
5 Runtime error 25 ms 10272 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Incorrect 4 ms 640 KB Integer 0 violates the range [1, 3000]
7 Incorrect 8 ms 1104 KB Integer 0 violates the range [1, 9000]
8 Runtime error 98 ms 14948 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 586 ms 66560 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 475 ms 66560 KB Execution killed with signal 11 (could be triggered by violating memory limits)