# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
98395 | 0_marchuk | Hokej (COCI17_hokej) | C++14 | 501 ms | 48372 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///-------------------///
//#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 (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |