Submission #4213663
Source Code Expand
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
unsigned long long max(unsigned long long current, unsigned long long k, unsigned long long a, unsigned long long b, bool doConvert){
if(!doConvert)
return current+k;
if(k==0)
return current;
if(k==1)
return current+1;
while(true){
//cout << current << ", " << k << endl;
if(!k)
return current;
else if(current<a){
if(k>=(a-current)){
k -= (a-current);
current = a;
}else{
current += k;
k=0;
}
}else{
if(k>1){
current += b-a;
k -= 2;
}else{
current++;
k--;
}
}
}
}
int main(){
unsigned long long current = 1;
unsigned long long k,a,b;
bool doConvert = true;
cin >> k >> a >> b;
if(b<=a)
doConvert = false;
else if(b-a<3)
doConvert = false;
unsigned long long res = max(current, k,a,b, doConvert);
cout << res << endl;
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - When I hit my pocket... |
| User | kkyusuke |
| Language | C++14 (GCC 5.4.1) |
| Score | 400 |
| Code Size | 1042 Byte |
| Status | AC |
| Exec Time | 648 ms |
| Memory | 256 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | s1.txt, s2.txt, s3.txt |
| All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, s1.txt, s2.txt, s3.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 01.txt | AC | 648 ms | 256 KiB |
| 02.txt | AC | 288 ms | 256 KiB |
| 03.txt | AC | 300 ms | 256 KiB |
| 04.txt | AC | 94 ms | 256 KiB |
| 05.txt | AC | 1 ms | 256 KiB |
| 06.txt | AC | 1 ms | 256 KiB |
| 07.txt | AC | 1 ms | 256 KiB |
| 08.txt | AC | 1 ms | 256 KiB |
| 09.txt | AC | 1 ms | 256 KiB |
| 10.txt | AC | 1 ms | 256 KiB |
| 11.txt | AC | 1 ms | 256 KiB |
| 12.txt | AC | 1 ms | 256 KiB |
| s1.txt | AC | 1 ms | 256 KiB |
| s2.txt | AC | 1 ms | 256 KiB |
| s3.txt | AC | 181 ms | 256 KiB |