Submission #141361

# Submission time Handle Problem Language Result Execution time Memory
141361 2019-08-07T14:09:11 Z SeekingOblivion Hokej (COCI17_hokej) C++14
0 / 120
503 ms 11272 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+=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 Incorrect 2 ms 380 KB Output isn't correct
2 Incorrect 8 ms 504 KB Output isn't correct
3 Incorrect 29 ms 888 KB Output isn't correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Incorrect 11 ms 628 KB Output isn't correct
6 Incorrect 5 ms 376 KB Output isn't correct
7 Incorrect 9 ms 504 KB Output isn't correct
8 Incorrect 90 ms 2424 KB Output isn't correct
9 Incorrect 502 ms 11216 KB Output isn't correct
10 Incorrect 503 ms 11272 KB Output isn't correct