# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
121027 |
2019-06-26T03:17:14 Z |
_Samir |
Hokej (COCI17_hokej) |
C++17 |
|
165 ms |
40644 KB |
#include<queue>
#include<map>
#include <string>
#include<bits/stdc++.h>
#define pi 3.141592654
#define forr(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define input ios_base::sync_with_stdio(0);cin.tie(0);
//#define x real()
//#define y imag()
using namespace std;
typedef pair<double,double>pdd;
typedef long long ll;
typedef pair<ll, ll>pii;
//typedef complex<double> point;
//template<typename T>T gcd(T x, T y) { if(y == 0)return x; else return gcd(y, x%y); }
//typedef bitset<30> mask;
//int x[8]={1,0,0,-1,-1,-1,1,1};
//int y[8]={0,1,-1,0,-1,1,-1,1};
//#define var(x) ((x)<<1)
//#define nvar(x) ((x)^1)
const int N=100000,M=100000;
int m,n,b[7][600000];
pair<pair<int,int>,int>a[600000];
ll sum;
main()
{
//cout<<Pow((ll)1000000,(ll)110);
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
// char input[15];
// scanf("%s", &input); array of char
// gets(c+1); array of char
//printf("%s, ",name[k[i]].c_str()); printf of string
//priority_queue<ll,vector<ll>,greater<ll>>y;
input;
cin>>m>>n;
forr(i,1,n)
cin>>a[i].F.F>>a[i].F.S,a[i].S=i;
sort(a+1,a+1+n);
reverse(a+1,a+1+n);
int idx=1,c=a[idx].F.S;
forr(i,1,6)
{
forr(j,1,m)
{
if(c)
{
b[i][j]=a[idx].S;
sum+=(ll)a[idx].F.F;
c--;
}
else
{
idx++;
c=a[idx].F.S;
b[i][j]=a[idx].S;
sum+=(ll)a[idx].F.F;
c--;
}
}
}
vector<pair<int,pair<int,int>>>ans;
forr(j,2,m)
{
int s=0;
forr(i,1,6)
{
if(b[i][j]!=b[i][j-1])
{
if(s==0)s=i;
if(b[i][j]==b[i+1][j-1])continue;
ans.push_back({j-1,{b[s][j-1],b[i][j]}});
s=0;
}
}
}
sort(ans.begin(),ans.end());
cout<<sum<<endl;
forr(i,1,6)cout<<b[i][1]<<" ";
cout<<endl<<(int)ans.size()<<endl;
for(auto p:ans)cout<<p.F<<" "<<p.S.F<<" "<<p.S.S<<endl;
/*
forr(j,1,m)
{
forr(i,1,6)cout<<b[i][j]<<" ";
cout<<endl;
}
*/
return 0;
}
Compilation message
hokej.cpp:29:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
main()
^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
640 KB |
Output is correct |
3 |
Runtime error |
34 ms |
25000 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Runtime error |
15 ms |
10240 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
6 |
Correct |
4 ms |
512 KB |
Output is correct |
7 |
Correct |
4 ms |
640 KB |
Output is correct |
8 |
Runtime error |
31 ms |
6136 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
9 |
Runtime error |
161 ms |
40568 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
10 |
Runtime error |
165 ms |
40644 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |