Niestety, nie byliśmy w stanie w pełni poprawnie wyświetlić tego pliku, ponieważ nie jest zakodowany w UTF-8.
Możesz pobrać ten plik i spróbować otworzyć go samodzielnie.
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
typedef long long LL;
typedef std::vector<LL> VLL;
constexpr auto MAX_A = 1000000002LL;
constexpr auto MAX_N = 500000;
int main()
{
int n;
auto _ = scanf("%d\n", &n);
VLL sumy(n);
VLL sumySort(n);
LL maxSum = 0;
for (int i = 0; i < n; i++)
{
LL sum;
auto _ = scanf("%lld", &sum);
sumy[i]=sumySort[i] = sum;
if (sum > maxSum) maxSum = sum;
}
std::sort(sumySort.begin(), sumySort.end());
LL fullSum = 0;
LL growSum = 0;
LL prev = 0;
LL granica = sumySort[0]; //granica po ktorej wszystkie sumy s� za ma�e zeby zjesc wszystkie inne
for (auto s : sumySort)
{
// nie sumuj elementow gdy przekroczy maksymalna wielkosc suma (to i tak nic nie zmieni a moze przepelnic)
if (fullSum < maxSum)
{
fullSum += s;
}
if (growSum > s)
{
growSum += s;
}
if (prev < s)
{
if (s > growSum)
{
granica = growSum;
}
growSum = fullSum;
}
prev = s;
if (growSum > maxSum || s==maxSum) break;
}
for (int i = 0; i < sumy.size(); i++)
{
printf("%c",sumy[i]<=granica ? 'N' : 'T');
}
printf("\n");
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | #define _CRT_SECURE_NO_WARNINGS #include <cstdio> #include <stdio.h> #include <iostream> #include <string.h> #include <math.h> #include <algorithm> #include <vector> typedef long long LL; typedef std::vector<LL> VLL; constexpr auto MAX_A = 1000000002LL; constexpr auto MAX_N = 500000; int main() { int n; auto _ = scanf("%d\n", &n); VLL sumy(n); VLL sumySort(n); LL maxSum = 0; for (int i = 0; i < n; i++) { LL sum; auto _ = scanf("%lld", &sum); sumy[i]=sumySort[i] = sum; if (sum > maxSum) maxSum = sum; } std::sort(sumySort.begin(), sumySort.end()); LL fullSum = 0; LL growSum = 0; LL prev = 0; LL granica = sumySort[0]; //granica po ktorej wszystkie sumy s� za ma�e zeby zjesc wszystkie inne for (auto s : sumySort) { // nie sumuj elementow gdy przekroczy maksymalna wielkosc suma (to i tak nic nie zmieni a moze przepelnic) if (fullSum < maxSum) { fullSum += s; } if (growSum > s) { growSum += s; } if (prev < s) { if (s > growSum) { granica = growSum; } growSum = fullSum; } prev = s; if (growSum > maxSum || s==maxSum) break; } for (int i = 0; i < sumy.size(); i++) { printf("%c",sumy[i]<=granica ? 'N' : 'T'); } printf("\n"); return 0; } |
English