Submission #26748

# Submission time Handle Problem Language Result Execution time Memory
26748 2017-07-05T11:11:57 Z model_code Programming Contest (POI11_pro) C++11
30 / 100
26 ms 1732 KB
/*************************************************************************
 *                                                                       *
 *                    XVIII Olimpiada Informatyczna                      *
 *                                                                       *
 *   Zadanie:           Konkurs programistyczny                          *
 *   Autor:             Pawel Parys                                      *
 *   Opis:              Rozwiazanie bledne - zachlanne                   *
 *                                                                       *
 *************************************************************************/


#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>

using namespace std;

struct assig {
   int c, t, s;
} a[1000];

int skill[500];
struct comp {
   bool operator()(const int &a, const int &b)
   {
     return skill[a] < skill[b];
   }
};

int n, m, r, t, k, pa;
int aa, bb;
vector<int> sv[600];
vector<pair<int, int> > dif;
bool v[600];

int main()
{
   scanf("%d %d %d %d %d", &n, &m, &r, &t, &k);
   for (int i = 0; i < k; i++)
   {
      scanf("%d %d", &aa, &bb);
      sv[bb - 1].push_back(aa - 1);
      skill[aa - 1]++;
   }
   for (int i = 0; i < m; i++)
      if (sv[i].size())
         dif.push_back(make_pair(sv[i].size(), i));
   sort(dif.begin(), dif.end());
   for (int i = 0; i < m; i++)
      if (sv[i].size())
         sort(sv[i].begin(), sv[i].end(), comp());
   int et = r;
   while (et <= t)
   {
      bool change = false;
      bool u[500];
      
      memset(u, false, sizeof(bool) * n);
      for (unsigned int i = 0; i < dif.size(); i++)
         if (!v[dif[i].second])
            for (vector<int>::iterator j = sv[dif[i].second].begin(); j != sv[dif[i].second].end(); j++)
               if (!u[*j])
               {
                  u[*j] = true;
                  v[dif[i].second] = true;
                  a[pa].c = *j;
                  a[pa].t = dif[i].second;
                  a[pa++].s = et - r;
                  change = true;
                  break;
               }

      if (!change) break;
      et += r;
   }
   int tm = 0;
   for (int i = 0; i < pa; i++)
      tm += a[i].s + r;
   printf("%d %d\n", pa, tm);
   for (int i = 0; i < pa; i++)
      printf("%d %d %d\n", a[i].c + 1, a[i].t + 1, a[i].s);
   return 0;
}

Compilation message

pro.cpp: In function 'int main()':
pro.cpp:39:47: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d %d %d %d %d", &n, &m, &r, &t, &k);
                                               ^
pro.cpp:42:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
       scanf("%d %d", &aa, &bb);
                               ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1204 KB It was possible to get penalty of 20418000 points and you received 20486060.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1204 KB It was possible to solve 95 problems and you solved only 92.
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1204 KB Output is correct
2 Correct 0 ms 1204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1336 KB Output is correct
2 Incorrect 3 ms 1336 KB It was possible to get penalty of 4389200 points and you received 4411146.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1732 KB Output is correct
2 Incorrect 23 ms 1732 KB It was possible to solve 494 problems and you solved only 493.
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 1732 KB It was possible to get penalty of 219191500 points and you received 220068266.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 23 ms 1732 KB Output is correct
2 Correct 9 ms 1468 KB Output is correct
3 Correct 0 ms 1204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 1336 KB Output is correct
2 Correct 19 ms 1732 KB Output is correct
3 Correct 26 ms 1732 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 1732 KB It was possible to get penalty of 500 points and you received 501.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1336 KB It was possible to solve 452 problems and you solved only 451.
2 Halted 0 ms 0 KB -