Submission #141364

# Submission time Handle Problem Language Result Execution time Memory
141364 2019-08-07T14:38:16 Z SeekingOblivion Hokej (COCI17_hokej) C++14
72 / 120
506 ms 6604 KB
#include<iostream>
#include<fstream>
#define fin cin
#define fout cout
#define f first
#define sf second.first
#define ss second.second
#include<algorithm>
using namespace std;
//ifstream fin("date.in");
//ofstream fout("date.out");
int m,n,i,l,p,start[6],mov,nr;
pair<int,pair<int,int> > v[500001],sol[1500001];
long long val;
int main(){
    fin>>m>>n;
    for(i=1;i<=n;i++){
        fin>>v[i].f>>v[i].sf;
        v[i].sf=min(v[i].sf,m);
        v[i].ss=i;
    }
    sort(v+1,v+n+1);
    l=0;p=0;
    for(i=n;i>=1;i--)
    {
        while(v[i].sf&&l<6)
        {
            if(p==0) start[l]=v[i].ss;
            else sol[++nr].f=p-1,sol[nr].sf=v[i+1].ss,sol[nr].ss=v[i].ss;
            if(p+v[i].sf-1>=m)
                mov=m-p,p=m-1;
            else
                mov=v[i].sf,p+=v[i].sf-1;
            v[i].sf-=mov;
            val+=1ll*mov*v[i].f;
            p++;
            if(p>=m) l++,p=0;
        }
    }
    fout<<val<<"\n";
    for(i=0;i<=5;i++) fout<<start[i]<<" ";
    fout<<"\n"<<nr<<"\n";
    sort(sol+1,sol+1+nr);
    for(i=1;i<=nr;i++)
        fout<<sol[i].f+1<<" "<<sol[i].sf<<" "<<sol[i].ss<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 8 ms 376 KB Output is correct
3 Correct 29 ms 632 KB Output is correct
4 Correct 3 ms 376 KB Output is correct
5 Correct 10 ms 476 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Incorrect 10 ms 376 KB Output isn't correct
8 Incorrect 92 ms 1668 KB Output isn't correct
9 Incorrect 500 ms 6392 KB Output isn't correct
10 Incorrect 506 ms 6604 KB Output isn't correct