Submission #3779509
Source Code Expand
#include <iostream> #include <algorithm> #include <vector> #include <map> #include <set> #include <string> #include <cmath> #include <iomanip> #include <queue> #include <unordered_map> #include <unordered_set> #include <bitset> #include <cassert> #include <cstring> using namespace std; #define FOR(i, a, b) for (int i = (a); i < (b); i++) #define REP(i, n) FOR(i, 0, n) #define SORT(c) sort((c).begin(), (c).end()) typedef long long ll; typedef pair<int, int> P; typedef vector<int> V; typedef map<int, int> M; constexpr ll INF = 1e18; constexpr ll MOD = 1e9 + 7; constexpr double PI = 3.14159265358979323846; constexpr int dx[] = {0, 0, 1, -1}; constexpr int dy[] = {1, -1, 0, 0}; int main() { ios::sync_with_stdio(false); cin.tie(0); int N, x, a[21234]; P a_[21234]; cin >> N >> x; REP(i, N) { cin >> a[i]; a_[i].first = a[i]; a_[i].second = i + 1; } sort(a_, a_ + N); bool used[21234] = {false}; int usedNum = 0; int i = 0; ll res = 0; ll res_x = 0; while (usedNum < N) { if (used[a_[i].second]) { i++; continue; } used[a_[i].second] = true; usedNum++; ll num = a_[i].first; int j = a_[i].second - 1; int cnt = 0; res += a_[i].first; while (true) { if (usedNum == N) break; num += x + a_[i].first; j++; if (j == N) j = 0; if (used[j + 1]) break; if (num > a[j]) break; usedNum++; used[j + 1] = true; res += a_[i].first; cnt++; } res_x = max(res_x, (ll)cnt * x); i++; } cout << res + res_x << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Slimes |
User | Kats |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1962 Byte |
Status | WA |
Exec Time | 2 ms |
Memory | 512 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 1 ms | 512 KB |
0_01.txt | AC | 1 ms | 512 KB |
0_02.txt | AC | 1 ms | 384 KB |
1_00.txt | AC | 2 ms | 512 KB |
1_01.txt | AC | 2 ms | 512 KB |
1_02.txt | AC | 2 ms | 512 KB |
1_03.txt | AC | 2 ms | 512 KB |
1_04.txt | WA | 2 ms | 512 KB |
1_05.txt | AC | 2 ms | 512 KB |
1_06.txt | WA | 2 ms | 512 KB |
1_07.txt | AC | 2 ms | 512 KB |
1_08.txt | WA | 2 ms | 512 KB |
1_09.txt | AC | 2 ms | 512 KB |
1_10.txt | WA | 2 ms | 512 KB |
1_11.txt | WA | 2 ms | 512 KB |
1_12.txt | WA | 2 ms | 512 KB |
1_13.txt | WA | 2 ms | 512 KB |
1_14.txt | WA | 2 ms | 512 KB |
1_15.txt | WA | 2 ms | 512 KB |
1_16.txt | WA | 2 ms | 512 KB |
1_17.txt | WA | 2 ms | 512 KB |