ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1100. Final Standings

Access violation, but works true om my pc! Help!
Posted by daniilmcrose 25 Dec 2012 16:01
#include <iostream>

using namespace std;

int main()
{
int** m;
long n;
cin>>n;
m = new int*[n];
for (long i=0; i<n; i++)
{
m[i]=new int[2];
m[i][1]=-1;
}

for (long j=0; j<n; j++)
{
    int g, t;
    cin>>g>>t;
    if (j==0)
    {
        m[0][0]=g;
        m[0][1]=t;
        continue;
    }
    else
    for (long i=0; i<=j; i++)
    {

        if (m[i][1]==t)
        while (m[i][1]==t && i<j)
        i++;
        else
        if (m[i][1]>t && m[i][i]!=-1) continue;

            if (i==j)
        {
            m[j][0]=g;
            m[j][1]=t;
            break;
        }

{
            for (long p=j; p>i; p--)
            {
            m[p][0]=m[p-1][0];
            m[p][1]=m[p-1][1];
            }
            m[i][0]=g;
            m[i][1]=t;
            break;
            }
            break;
        }
}
for (int i=0; i<n ;i++)
{
cout<<m[i][0]<<" "<<m[i][1]<<'\n';
}
delete[] *m;
return 0;
}
Re: Access violation, but works true om my pc! Help!
Posted by Majin Boo 1 Nov 2015 06:25
Is not advisable to use dynamic memory. I recommend you use STL <vector>