QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#657422#5301. Modulo Ruins the LegendShiyuKiraraTL 0ms0kbC++203.3kb2024-10-19 14:44:112024-10-19 14:44:14

Judging History

This is the latest submission verdict.

  • [2024-10-19 14:44:14]
  • Judged
  • Verdict: TL
  • Time: 0ms
  • Memory: 0kb
  • [2024-10-19 14:44:11]
  • Submitted

answer

#include <bits/stdc++.h>
#define inf 1e18
using namespace std;
using ll = long long;
#define int long long
#define PII pair<int, int>
#define all(a) a.begin() + 1, a.begin() + 1 + n
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
#define ios ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
const ll N = 2e5 + 10, mod = 998244353, INF = 1e9 + 10;
void solve()
{
    int n, m;
    cin >> n >> m;
    vector<ll> a(n + 10);
    int sum = 0;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    int mn = sum % m;
    int aa = 0, bb = 0;
    int dd = n * (n + 1) / 2;
    for (int i = 0; i <= 100000; i++)
    {
        for (int j = 0; j <= 100000; j++)
        {
            if ((sum + n * i) % m < mn)
                mn = (sum + n * i) % m, aa = i, bb = 0;
            if ((sum + dd * j) % m < mn)
                mn = (sum + dd * j) % m, aa = 0, bb = j;
            if((sum+n*i+dd*j)%m<mn)
                mn=(sum+n*i+dd*j)%m,aa=i,bb=j;
        }
    }
    cout << mn << endl << aa << " " << bb;
}
signed main()
{
    ios;
    int T = 1;
    //     cin>>T;
    while (T--)
    {
        solve();
    }
    return 0;
}
// Shift+Alt+F格式化
// ⠀⠀⠀⢛⢆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠤⠀⠀⠂⣠⡀⢀⣀⠀⠠⢄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠠⡄⠀⠀⠀
// ⠀⠀⠀⠀⠀⠈⠀⠀⠀⠀⠀⠀⠀⢀⢤⢤⡘⠀⠀⠀⠀⠔⠋⠘⢆⠀⠙⢦⠀⠑⠢⡀⠀⠀⠀⠀⠀⠀⠀⠀⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠣⠀⠀⠀⠀⠠⢢⠃⠀⠈⠀⠀⠀⠀⠀⠀⠉⢿⣷⡀⠀⠑⡄⠀⠈⢢⠀⠀⢀⡀⠀⢰⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⡀⠀⠀⠰⠡⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢻⣧⠀⠀⠙⠀⠀⠀⣇⠀⠀⠀⠀⠚⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠰⣇⠀⠰⠁⠀⠀⠀⠀⣴⠀⠀⠀⠀⠰⢧⠀⠀⠘⣿⡄⠀⠀⠀⠀⠰⡌⣱⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠤⠀⠀⠉⠀⡁⠀⠀⢠⠀⠀⢎⡆⠀⠀⠀⠐⡤⠵⢖⢲⣿⣇⠀⠀⠰⣦⣦⡈⢫⣃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⢠⡀⠀⠀⢀⡅⣤⠀⣼⠒⠞⣀⡣⣤⣤⣤⣴⢷⣤⣤⠷⣮⢿⠀⠀⠀⠀⠈⠹⡰⠳⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⠃⣿⣀⣿⡾⢷⡖⢶⡄⠉⠁⠈⠀⢏⠁⠉⠹⢘⠀⠀⠀⠀⠀⠀⣼⠷⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡏⣿⡄⠘⠧⡁⠀⠇⠀⠀⠀⠀⠈⠀⠀⠀⠈⠀⠀⣾⣦⣶⣤⣿⣦⠲⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣠⢁⢹⣇⠀⠀⠀⠀   ~~~     ⠈⣠⠀⠀⣿⣿⣿⣿⡿⣿⣧⡘⢄⠀⠈⠀⠀⠀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠁⣾⢸⣿⣦⣀⠂⠀⠀⠀⠀⠀⠀⠀⠀⠔⠊⢹⠀⠀⡹⠛⠟⠁⠠⣇⠛⠿⢦⡑⢄⠀⠀⠄⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠀⠈⠀⠀⢠⣈⣸⡟⠁⠈⡹⠛⠉⠉⠉⢒⡀⢔⠁⠀⠀⢸⣿⣿⣷⠀⠀⢀⡠⡚⢦⣒⣄⠈⠀⠑⠤⡀⠀⠀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⠐⠁⢀⡠⢺⣿⣿⡟⠀⠀⠈⠢⠇⠀⡀⢺⡶⣾⣕⣄⡀⣼⣿⣿⡿⠀⠉⠁⠀⠘⡄⠱⢿⣿⣄⡀⠑⠌⠢⡀⠀⠀⠀⠀
// ⠀⠀⠀⠀⠀⠀⢀⠴⣋⢠⣾⣿⣿⡁⠀⠀⠀⠀⠀⡸⢁⣿⠇⣿⢻⣷⡍⢾⣿⣿⣿⡄⠀⠀⠀⠀⣸⢧⠈⢻⣿⣿⣦⣀⣀⢠⠀⠀⠀⠀

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Time Limit Exceeded

input:

6 24
1 1 4 5 1 4

output:


result: